【Azure Developer】use @azure/arm-monitor sdk 遇见 ManagedIdentityCredential authentication failed.(status code 500)

azure,developer,use,arm,monitor,sdk,遇见,managedidentitycredential,authentication,failed,status,code · 浏览次数 : 5

小编点评

**问题描述:** 在使用 @azure/arm-monitor sdk 创建 MonitorClient 对象时,遇到错误:`ManagedIdentityCredential authentication failed.(status code 500)CredentialUnavailableError: ERROR: AADSTS500011: The resource principal name https://management.azure.com was not found in tenant name ##############. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant.` **解决方法:** 1. **添加 credentialScopes 参数:** ```javascript const credentialScopes = ['https://management.chinacloudapi.cn/.default']; ``` 2. **在 MonitorClient 构造函数中设置 credentialScopes 参数:** ```javascript const client = new MonitorClient(tokenCredential, 'my-resource-group', { credentialScopes: credentialScopes, }); ``` **注意:** * `credentialScopes` 要包含要使用的资源凭据的资源 principal名称。 * `my-resource-group` 是您的资源组名称。 * `tokenCredential` 是您的 OAuth 凭据。

正文

问题描述

在使用 @azure/arm-monitor sdk 创建 MonitorClient对象时候,遇见错误 ManagedIdentityCredential authentication failed.(status code 500)

CredentialUnavailableError: ERROR: AADSTS500011: The resource principal name https://management.azure.com was not found in tenant name ##############. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You might have sent your authentication request to the wrong tenant.

 

问题解决

在初始化 MonitorClient 对象时,添加 credentialScopes 参数:

credentialScopes: ['https://management.chinacloudapi.cn/.default']

即可解决问题。

 

 

参考资料

 

 

与【Azure Developer】use @azure/arm-monitor sdk 遇见 ManagedIdentityCredential authentication failed.(status code 500)相似的内容:

【Azure Developer】use @azure/arm-monitor sdk 遇见 ManagedIdentityCredential authentication failed.(status code 500)

@azure/arm-monitor ManagedIdentityCredential authentication failed.(status code 500) CredentialUnavailableError: ERROR: AADSTS500011: The resource principal name https://management.azure.com was not

【Azure Developer】如何通过Azure Portal快速获取到对应操作的API并转换为Python代码

问题描述 对于Azure资源进行配置操作,门户上可以正常操作。但是想通过Python代码实现,这样可以批量处理。那么在没有SDK的情况下,是否有快速办法呢? 问题解答 当然可以,Azure Portal上操作的所有资源都是通过REST API来实现的,所以只要找到正确的API,就可以通过浏览器中抓取

【Azure Developer】.Net 简单示例 "文字动图显示" Typing to SVG

问题描述 看见一个有趣的页面,可以把输入的文字信息,直接输出SVG图片,还可以实现动图模式。 示例URL: https://readme-typing-svg.demolab.com/?font=Fira+Code&pause=1000&color=F7F7F7&background=233911F

【Azure Developer】示例: 在中国区调用MSGraph SDK通过User principal name获取到User信息,如Object ID

问题描述 示例调用MSGraph SDK通过User principal name获取到User信息,如Object ID。 参考资料 选择 Microsoft Graph 身份验证提供程序 : https://learn.microsoft.com/zh-cn/graph/sdks/choose-

【Azure Developer】在App Service上放置一个JS页面并引用msal.min.js成功获取AAD用户名示例

问题描述 在App Service上放置一个JS页面并引用msal.min.js,目的是获取AAD用户名并展示。 问题解答 示例代码 Azure Service

【Azure Developer】Springboot 集成 中国区的Key Vault 报错 AADSTS90002: Tenant 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' not found

spring.cloud.azure.keyvault.secret.property-sources[0].profile.cloud-type=AZURE_CHINA

【Azure Developer】开发模式下使用AAD账号访问Azure Blob的相关参考

问题描述 开发模式下使用AAD账号访问Azure Blob的流程参考文件 问题解答 第一步:先在AAD中注册一个APP,步骤可参考: 将应用程序注册到 Microsoft 标识平台 :https://docs.azure.cn/zh-cn/active-directory/develop/quick

【Azure Developer】Go语言调用Azure SDK如何登录到中国区Azure环境

问题描述 在 “使用 Azure SDK for Go 进行 Azure 身份验证” 文章中的 Go 示例代码进行登录Azure时,默认指向的是Globa Azure。当只修改AAD AZURE_CLIENT_ID , AZURE_TENANT_ID 和 AZURE_CLIENT_SECRET参数值

【Azure Developer】Github Action使用Azure/login@v1插件登录遇见错误的替代方案

问题描述 在使用 Github Action - Azure/login@v1 的插件时候,登录中国区Azure遇见了问题。 Login YAML 内容: - name: 'Login via Azure CLI' uses: Azure/login@v1.4.6 with: creds: ${{

【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image

问题描述 使用Github Action,通过 Azure/functions-container-action@v1 插件来完成 yaml 文件的配置,并成功部署Function Image 的过程记录。 操作步骤 第一步: 准备Function的镜像文件 如在VS Code中,通过Termina