首页 > 其他分享 >azure.core.exceptions.ClientAuthenticationError: Authentication failed: AADSTS500011处理方案

azure.core.exceptions.ClientAuthenticationError: Authentication failed: AADSTS500011处理方案

时间:2023-01-03 18:11:52浏览次数:57  
标签:ClientAuthenticationError core resource failed client azure group id tenant

源代码:

ml_client = MLClient(
            credential=ClientSecretCredential(
                tenant_id=tenant_id,
                client_id=client_id,
                client_secret=client_secret,
                authority=AzureAuthorityHosts.AZURE_CHINA
            ),
            subscription_id=subscription_id,
            resource_group_name=resource_group,
            workspace_name=workspace
            )
View Code

报异常如下:

azure.core.exceptions.ClientAuthenticationError: Authentication failed: AADSTS500011: The resource principal named https://management.azure.com was not found in the tenant named Ecolab. 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.

解决方案:

kwargs = {"cloud": "AzureChinaCloud"}
        ml_client = MLClient(
            credential=ClientSecretCredential(
                tenant_id=tenant_id,
                client_id=client_id,
                client_secret=client_secret,
                authority=AzureAuthorityHosts.AZURE_CHINA
            ),
            subscription_id=subscription_id,
            resource_group_name=resource_group,
            workspace_name=workspace,
            **kwargs
            )
View Code

究其原因是中国区的azure应该把https://management.azure.com改为https://management.chinacloudapi.cn即可。

标签:ClientAuthenticationError,core,resource,failed,client,azure,group,id,tenant
From: https://www.cnblogs.com/donchen/p/17023047.html

相关文章