手工修复Azure DevOps无法连接到Azure的问题
點(diǎn)擊上方藍(lán)字關(guān)注“汪宇杰博客”
今天我在為一個(gè)從TFVC遷移到Git的老項(xiàng)目重新配置發(fā)布到Azure App Service的CI/CD管線的時(shí)候,Azure DevOps竟然爆了。這是一個(gè)微軟已知的bug,目前還未修復(fù),我來帶大家看看如何手工workaround這個(gè)問題。
首先,部署的時(shí)候報(bào)錯(cuò)消息如下:
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
本質(zhì)上是因?yàn)锳zure DevOps到Azure的連接無效,或者過期了。但是當(dāng)我嘗試重新認(rèn)證的時(shí)候,竟然又爆了:
TF14045: The identity with type 'Microsoft.IdentityModel.Claims.ClaimsIdentity' could not be found.
對(duì)此,微軟有個(gè)已知bug可以追蹤:https://developercommunity.visualstudio.com/content/problem/412380/tf14045-the-identity-with-type-microsoftidentitymo-1.html
解決方法
進(jìn)入 Azure Active Directory > App registrations (Preview)
點(diǎn)擊 "+ New registration"
指定一個(gè) Name,如 ediwang-AzureDevOps
選擇 "Accounts in this organizational directory only"
Redirection URL 填: https://VisualStudio/SPN
Description 任意,Expires 建議選 Never
然后把 Client Secrets 里的密鑰復(fù)制出來
還有Overview 里的 Application (client) ID 以及 Directory (tenant) ID
然后到 Subscription > Access control (IAM) 里搜索剛才創(chuàng)建的App名字,搜到以后,Add a role assignment
然后安排一個(gè) Owner,Azure這邊就搞定了!
然后回到 Azure DevOps
在 Azure App Service Deploy 的任務(wù)里點(diǎn) Manage?
在 Service Connections 里添加一個(gè) Azure Resource Manager
然后點(diǎn)“use the full version of the service connection dialog.”
選擇和輸入對(duì)應(yīng)的值。其中 Service pricipal client ID 就是剛才復(fù)制的 Application (client) ID,Service pricipal key 就是剛才?Client Secrets 里復(fù)制的 VALUE
最后點(diǎn)擊 Verify connection,不成功便成仁!
到此為止,就全部搞定了。重新回到你的部署任務(wù)里,就能成功選擇目標(biāo)Azure App Service上的網(wǎng)站了,并且能部署成功。
真是不容易……
總結(jié)
以上是生活随笔為你收集整理的手工修复Azure DevOps无法连接到Azure的问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【NET CORE微服务一条龙应用】应用
- 下一篇: 如何用EFCore Lazy Loadi