【Azure Developer】VS Code无法连接到中国区Azure解决之法 - LuBu0505/My-Code GitHub Wiki

问题描述

VS Code的Azure Resource插件,在设置Account为China Azure后,依旧无法连接到China Azure  image.png

点击Sign in Azure,依旧是打开的Global Azure的登录URL: 

https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize?response_type=code&response_mode=query&client_id=aebc6443-996d-45c2-90f0-388ff96faa56&redirect_uri=https%3a%2f%2fvscode.dev%2fredirect&scope=email+https%3a%2f%2fmanagement.core.windows.net%2f.default+offline_access+openid+profile&prompt=select_account&code_challenge_method=S256&code_challenge=0P05IuCMEXtNbHq9vVwOtNU8emWofr8uI7lR39Hihwc&state=http%3a%2f%2f127.0.0.1%3a60775%2fcallback%3fnonce%3dLQTfzt8GXWQd3IZOZQS8DQ%253D%253D&sso_nonce=AwABEgEAAAACAOz_BQD0_9ACvamMY_mXyz8ElL7YiHTOHu0LPjfvrmJJ95CCOiU8ufZ6bEuuDp7DOMOUs4D78g3exD8YKLSwN8p0r3u6EZkgAA&client-request-id=5c540786-f7cc-4c79-adc1-dc832bcfe1de&mscrid=5c540786-f7cc-4c79-adc1-dc832bcfe1de

问题解答

查看Github上的介绍 “ can't login to Azure china with VS code Azure tools extension ”,  这是因为 Azure Resource的扩展插件在V0.8.0之后进行了升级,迁移了内置的Microsoft身份认证。新的版本中需要配置的是“microsoft-sovereign-cloud.environment”。把它的值设置为ChinaCloud即可。

操作步骤如下图: image.png

参考资料

can't login to Azure china with VS code Azure tools extension #946 : https://github.com/microsoft/vscode-azure-account/issues/946

To connect to a sovereign cloud, set the microsoft-sovereign-cloud.environment setting. This is new as of v0.8.0 and is a result of our migration to the built-in Microsoft authentication extension which replaces the Azure Account extension. Learn more in the release notes.

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!