【Azure Developer】使用Azure Developer CLI (azd)部署項目時候遇見無法登錄中國區(qū)Azure的報錯
問題描述
使用 Azure Developer CLI (azd) 部署Aspire應(yīng)用到Azure China中, 在2025年10月10號運行卻報錯無法登錄,報錯##[error]Bash exited with code '1'. 而在之前均能正常登錄的。

詳細錯誤信息:
2025-10-09T22:07:47.5065424Z ##[section]Starting: login to azd auth
2025-10-09T22:07:47.5071300Z ==============================================================================
2025-10-09T22:07:47.5071433Z Task : Command line
2025-10-09T22:07:47.5071518Z Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
2025-10-09T22:07:47.5071637Z Version : 2.250.1
2025-10-09T22:07:47.5071704Z Author : Microsoft Corporation
2025-10-09T22:07:47.5071802Z Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
2025-10-09T22:07:47.5071913Z ==============================================================================
2025-10-09T22:07:47.6636821Z Generating script.
2025-10-09T22:07:47.6637165Z ========================== Starting Command Output ===========================
2025-10-09T22:07:47.6638152Z [command]/usr/bin/bash --noprofile --norc /home/vsts/work/_temp/xxx-x-x-xxxx.sh
2025-10-09T22:07:49.0741040Z
2025-10-09T22:07:49.0742412Z ERROR: ClientSecretCredential: unable to resolve an endpoint: ResolveEndpoints(): TenantDiscoveryResponse: issuer from OIDC discovery
'https://login.partner.microsoftonline.cn/<tenant id>/v2.0' does not match authority 'https://login.chinacloudapi.cn/<tenant id>/' or a known pattern2025-10-09T22:07:49.0766912Z
2025-10-09T22:07:49.0831041Z ##[error]Bash exited with code '1'.
2025-10-09T22:07:49.0874244Z ##[section]Finishing: login to azd auth
如何來解決這個問題呢?
問題解答
在對比之前執(zhí)行成功的腳本內(nèi)容,腳本并沒有變化,排除腳本的錯誤。而后查看azd 的release notes,發(fā)現(xiàn)剛好最新發(fā)布的新版本為1.20.0
執(zhí)行腳本:
- task: Bash@3
displayName: Install azd
inputs:
targetType: 'inline'
script: |
curl -fsSL https://aka.ms/install-azd.sh | bash
- script: |
azd version
azd config set cloud.name AzureChinaCloud
azd auth login --client-id $(AZURE_CLIENT_ID) --client-secret $(AZURE_CLIENT_SECRET) --tenant-id $(AZURE_TENANT_ID)
displayName: 'login to azd auth'
azd 的 Release Notes:
Reference Link : https://github.com/Azure/azure-dev/releases/tag/azure-dev-cli_1.20.0

鑒于懷疑是 azd 版本升級導(dǎo)致,所以解決的思路就是 回滾到1.20.0 的前一個版本 1.19.0 。
在Linux系統(tǒng)中,安裝azd的特定版本可以通過如下腳本:
curl -fsSL https://aka.ms/install-azd.sh | bash -s -- --version 1.19.0
然后,執(zhí)行azd auth login命令,成功。問題得到解決!
所以,當遇見最新版本的azd無法登錄時候,最快的辦法就是通過回滾來解決!
參考資料
Install or update the Azure Developer CLI : https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd?tabs=winget-windows%2Cbrew-mac%2Cscript-linux&pivots=os-linux
當在復(fù)雜的環(huán)境中面臨問題,格物之道需:濁而靜之徐清,安以動之徐生。 云中,恰是如此!

浙公網(wǎng)安備 33010602011771號