1

我在我们的天蓝色环境中创建了一个工作区并尝试运行此代码:

library(azuremlsdk)

ws <- get_workspace(
    name = "someworkspace", 
    subscription_id = "si1", 
    resource_group ="rg1"
)

一些交互式身份验证器在我的浏览器中打开,我认为这是预期的行为,因为我没有租户。但是,我明白了:

Performing interactive authentication. Please follow the instructions on the terminal.
Note, we have launched a browser for you to login. For old experience with device code, use "az login --use-device-code"
You have logged in. Now let us find all the subscriptions to which you have access...
Interactive authentication successfully completed.
Performing interactive authentication. Please follow the instructions on the terminal.
Note, we have launched a browser for you to login. For old experience with device code, use "az login --use-device-code"
You have logged in. Now let us find all the subscriptions to which you have access...
Interactive authentication successfully completed.
AuthenticationException: AuthenticationException:
        Message: Could not retrieve user token. Please run 'az login'
        InnerException It is required that you pass in a value for the "algorithms" argument when calling decode().
        ErrorResponse
{
    "error": {
        "code": "UserError",
        "inner_error": {
            "code": "Authentication"
        },
        "message": "Could not retrieve user token. Please run 'az login'"
    }
}

我也试过:

az login

这工作正常。所以对我来说,这一切都非常令人困惑!

4

2 回答 2

2

所以我在 Python 中尝试了同样的方法并且遇到了类似的错误并遇到了这个:

https://github.com/Azure/azure-sdk-for-python/issues/16035

降级:

 PyJWT 

帮助。开源的奇异世界及其相互依赖的网络!

于 2021-05-11T16:55:59.740 回答
0

正如@cs0815 提到的,这个 Github 问题帮助我解决了这个问题: https ://github.com/Azure/azure-sdk-for-python/issues/16035

我做了什么来解决这个问题?

1.检查包版本

当我运行以下命令时,我拥有 azure-core 版本 1.15.0:

pip show azure-core

运行此命令时,我拥有的 PyJWT 是 2.1.0:

pip show PyJWT

2. 将 PyJWT 降级到 1.7.1

为此,我运行以下命令:

python -m pip install --upgrade PyJWT==1.7.1

3.检查工作区连接

我运行此 Python 脚本以连接到我的 Azure 机器学习工作区:

import azureml.core
from azureml.core import Workspace

print("Ready to use Azure ML", azureml.core.VERSION)

#Store first the workspace connection information in a JSON.
#This can be downloaded from the Azure portal or the workspace details
#pane in Azure Machine Learning studio.
ws = Workspace.from_config('config.json')
print(ws.name, "loaded")
于 2021-06-23T08:45:28.383 回答