问题描述

使用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 )催促微软修复此问题。

 

参考资料

 


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