无效的身份验证令牌租户

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

0

我正在尝试使用 Azure 计算集群,并且我正在尝试使用以下代码片段构建一个环境作为该过程的一部分。

from azure.ai.ml import MLClient
from azure.identity import DefaultAzureCredential

# import required libraries for environments examples

from azure.ai.ml.entities import Environment, BuildContext

# Enter details of your Azure Machine Learning workspace

subscription_id = "\<The subscription_id \>"
resource_group = "The resource_group "
workspace = "The workspace"

# connect to the workspace

ml_client = MLClient(
DefaultAzureCredential(), subscription_id, resource_group, workspace,
)

env_docker_conda = Environment(
image="mcr.microsoft.com/azureml/curated/acpt-pytorch-2.1-cuda12.1:10",
conda_file="/path to conda env file",
name="name of env",
description="description of env",
)
ml_client.environments.create_or_update(env_docker_conda)

运行时出现以下错误(从最后一行开始):

azure.core.exceptions.ClientAuthenticationError:(InvalidAuthenticationTokenTenant)访问令牌来自错误的颁发者“https://sts.windows.net/33e01921-4d64-4f8c-a055-5bdaffd5e33d/”。它必须匹配与此订阅关联的租户“https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/”。请使用权限(URL)“https://login.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47”获取令牌。请注意,如果订阅转移到另一个租户,不会对服务产生影响,但有关新租户的信息可能需要一些时间才能传播(最多一个小时)。如果您刚刚转移订阅并看到此错误消息,请稍后再试。

到目前为止我已经尝试过以下方法

az login --tenant '租户 id' az account set --subscription '订阅 id' 在 azure cli 中并设置 os.environ['AZURE_TENANT_ID']="我的租户 id"

错误信息中的权限(URL)导致页面未找到页面。

azure azure-ai
1个回答
0
投票

您必须从您申请注册的帐户登录。

我尝试使用

InteractiveBrowserCredential
使用我的个人帐户登录,但出现了同样的错误。

enter image description here

重新启动笔记本中的内核并尝试如下所示的

InteractiveBrowserCredential

ml_client = MLClient(
    InteractiveBrowserCredential(),
    "subscription_id", 
    "resource_group", 
    "jgsml"
)

然后选择您的应用程序注册的正确帐户。

如果您使用正确的帐户并且仍然面临问题,请确保您尝试访问的 Azure 订阅与正确的 Azure Active Directory 租户关联。

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