【Azure 環境】VS Code登錄China Azure(Function)報錯 An error occurred while signing in: invalid_request - AADSTS65002
問題描述
使用VS Code登錄到中國區Azure,想發布部署Azure Function。但是在登錄的時候就遇見了錯誤:An error occurred while signing in: invalid_request - AADSTS65002
完整的消息為:
An error occurred while signing in: invalid_request - AADSTS65002: Consent between first party application 'c27c220f-ce2f-4904-927d-333864217eeb' and first party resource '797f4846-ba00-4fd7-ba43-dac1f8f63013' must be configured via preauthorization - applications owned and operated by Microsoft must get approval from the API owner before requesting tokens for that API.
'c27c220f-ce2f-4904-927d-333864217eeb' 和 '797f4846-ba00-4fd7-ba43-dac1f8f63013' 這兩個ID代表什么意思呢?
問題解答
簡而言之,該錯誤指出兩個 GUID(應用 ID 和資源 ID)之間缺少預先授權導致登錄失敗。
而這兩個ID代表的意思是:
- 'c27c220f-ce2f-4904-927d-333864217eeb' : Visual Studio Code 的 Azure 登錄應用程序ID(Microsoft 第一方客戶端)。它屬于 VS Code 擴展,用于獲取訪問Azure資源的令牌。
- '797f4846-ba00-4fd7-ba43-dac1f8f63013' : Azure Service Management (Azure Resource Manager) 的應用程序ID(Microsoft 第一方資源)。這是Azure管理服務在AAD中的固定標識。
AADSTS65002 并非用戶配置錯誤,而是微軟端應用配置的問題。普通用戶也無法手動授予該權限(Azure AD不接受對第一方應用組合的同意)。只能等待微軟修復預授權配置或者使用替代辦法登錄(比如臨時使用Azure CLI等已授權途徑)。
如果VS Code此前登錄正常,只是最近才出現此類問題,可以考慮通過回退VS Code的Azure Account插件版本來嘗試緩解此問題。 或者是通過更新VS Code到最新版本。 除此之外,可以反饋到Github( https://github.com/microsoft/vscode/issues/244689 )催促微軟修復此問題。
參考資料
無
當在復雜的環境中面臨問題,格物之道需:濁而靜之徐清,安以動之徐生。 云中,恰是如此!

浙公網安備 33010602011771號