原标題:手工修複Azure DevOps無法連接配接到Azure的問題
今天我在為一個從TFVC遷移到Git的老項目重新配置釋出到Azure App Service的CI/CD管線的時候,Azure DevOps竟然爆了。這是一個微軟已知的bug,目前還未修複,我來帶大家看看如何手工workaround這個問題。
首先,部署的時候報錯消息如下:
Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resourcename 'moonglade'. Error: Could not fetch access token for Managed ServicePrincipal. Please configure Managed Service Identity (MSI) for virtual machine'https://aka.ms/azure-msi-docs'.Status code: 400, status message: Bad Request
本質上是因為Azure DevOps到Azure的連接配接無效,或者過期了。但是當我嘗試重新認證的時候,竟然又爆了:
TF14045: The identity with type 'Microsoft.IdentityModel.Claims.ClaimsIdentity' could not be found.
對此,微軟有個已知bug可以追蹤:https://developercommunity.visualstudio.com/content/problem/412380/tf14045-the-identity-with-type-microsoftidentitymo-1.html
解決方法
進入 Azure Active Directory > App registrations (Preview)
點選 "+ New registration"
指定一個 Name,如 ediwang-AzureDevOps
選擇 "Accounts in this organizational directory only"
Redirection URL填: https://VisualStudio/SPN
Deion任意,Expires建議選 Never
然後把 Client Secrets裡的密鑰複制出來
還有Overview裡的 Application (client) ID以及 Directory (tenant) ID
然後到 Subion > Access control (IAM)裡搜尋剛才建立的App名字,搜到以後,Add a role assignment
然後安排一個 Owner,Azure這邊就搞定了!
然後回到 Azure DevOps
在 Azure App Service Deploy的任務裡點 Manage
在 Service Connections裡添加一個 Azure Resource Manager
然後點“use the full version of the service connection dialog.”
選擇和輸入對應的值。其中 Service pricipal client ID就是剛才複制的 Application (client) ID,Service pricipal key就是剛才 Client Secrets裡複制的 VALUE
最後點選 Verify connection,不成功便成仁!
到此為止,就全部搞定了。重新回到你的部署任務裡,就能成功選擇目标Azure App Service上的網站了,并且能部署成功。
責任編輯: