Azure 机器学习:访问令牌来自错误的颁发者

问题描述 投票:0回答:1

我是 Azure 云新手,正在使用我的 Microsoft Azure 云个人帐户。我已使用此资源安装了适用于 Python 的 Azure ML 客户端库。

我正在尝试使用

MLClient

连接到本地计算机上基于 Ubuntu 22.04 的 Azure 机器学习客户端

当我尝试使用

DefaultAzureCredential
甚至
InteractiveBrowserCredential
中的
azure.identity
来代替
MLClient
时,我收到此错误:

InvalidAuthenticationTokenTenant
Message: The access token is from the wrong issuer 'https://sts.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/'. It must match the tenant 'https://sts.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx/' associated with this subscription. Please use the authority (URL) 'https://login.windows.net/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx' to get the token.

这是我正在使用的代码片段:

from azure.ai.ml import MLClient
from azure.identity import InteractiveBrowserCredential, DefaultAzureCredential
ml_client = MLClient(
    InteractiveBrowserCredential(),
    subscription_id, 
    resource_group, 
    workspace
)

我从默认的

subscription_id
中取出了
resource_group 
workspace
config.json
。使用
InteractiveBrowserCredential
,我被引导到浏览器进行身份验证,这是成功的,但随后它陷入了上述错误。 我也使用过
DefaultAzureCredential
,同时使用
AZURE_TENANT_ID
设置环境变量
AZURE_CLIENT_ID 
AZURE_CLIENT_SECRET
export AZURE_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
,但最终结果总是相同的错误。

我已经完成了solution-1solution-2,但根据我的理解,这些与我的案例无关。

关于这个官方文档,它谈到了组织,我怀疑我不是其中的一部分,因为我使用的是我的个人帐户。

azure azure-machine-learning-service azure-sdk-python
1个回答
0
投票

问题是您正在尝试访问不同租户中的资源,或者您的资源已移至不同租户。您登录的帐户应该已注册。

按照此堆栈解决方案寻求帮助。

此外,尝试使用

ClientSecretCredential
而不是设置
AZURE_TENANT_ID
AZURE_CLIENT_ID
AZURE_CLIENT_SECRET
环境变量。

使用以下代码:

ml_client = MLClient(
    ClientSecretCredential(client_id="client_id", tenant_id="tenant_id", client_secret="secret"),
    "subscription_id", 
    "resource_grp", 
    "jgsml"
)

如果错误仍然存在,我建议重新启动内核并再次检查。

© www.soinside.com 2019 - 2024. All rights reserved.