【Azure 環境】連線到微軟雲Azure中國區 By VS 2019, VS Code, Powershell
問題情形
最近,在使用最新的VS Code外掛連線到中國區的Azure時候,出現了依舊是global版的登入連線。這個問題是當前Azure Account外掛最新版的問題,可以使用V0.8.11版本登入到中國區。發現有這個問題的時間點為2020-08-25,如過1~2後,問題應已經被修復。
連線中國區Azure的方法:
1) 使用VS Code, 在安裝好Azure Account外掛後,進入Setting -> 輸入“Azure Configuration”過濾,在Extensions中選擇Azure Configuration,在Azure Cloud一欄中選擇“AzureChina”。即可。
2) 使用VS 2019登入中國區Azure, 前提條件需要先安裝好Azure開發的元件後。可以開啟Tools中的Options視窗,在Environment的Accounts中,新增Azure In China的註冊項。
當需要釋出應用到Azure上時候,這可以在Publish視窗中選擇登入賬號,然後釋出。
3) 使用Powershell登入,這裡目前推薦使用CLI命令登入,需要您先安裝az模組。你可以使用以下的命令安裝和登入中國區Azure。
安裝az模組:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
登入命令
az cloud set --name AzureChinaCloud az login -u [email protected] -p xxxxxxxx
或者是
Connect-AzAccount -Environment AzureChinaCloud
參考資料:
VS Code登入中國區Azure: https://docs.azure.cn/zh-cn/articles/azure-operations-guide/others/aog-others-howto-login-china-azure-by-vscode
Powershell: https://docs.azure.cn/zh-cn/role-based-access-control/role-assignments-powershell
Powershell登陸中國區的命令: https://docs.microsoft.com/zh-cn/powershell/azure/authenticate-azureps?view=azps-4.4.0#sign-in-to-another-cloud
Powershell設定訂閱: https://docs.microsoft.com/zh-cn/powershell/azure/manage-subscriptions-azureps?view=azps-4.4.0#change-the-active-subscription