使用azd部署项目时,为何无法登录中国区Azure账号?

摘要:问题描述 使用 Azure Developer CLI (azd) 部署Aspire应用到Azure China中, 在2025年10月10号运行却报错无法登录,报错##[error]Bash exited wit
问题描述 使用Azure Developer CLI (azd) 部署Aspire应用到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 pattern 2025-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 如何来解决这个问题呢? 问题解答 在对比之前执行成功的脚本内容,脚本并没有变化,排除脚本的错误。而后查看azd 的release notes,发现刚好最新发布的新版本为1.20.0 执行脚本: - 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 版本升级导致,所以解决的思路就是 回滚到1.20.0 的前一个版本 1.19.0 。 在Linux系统中,安装azd的特定版本可以通过如下脚本: curl-fsSLhttps://aka.ms/install-azd.sh|bash-s----version1.19.0 然后,执行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