获取工作区失败 azuremlsdk - AuthenticationException

问题描述

我在 azure 环境中创建了一个工作区并尝试运行此代码

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,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

我也试过:

t1 = read.dendrogram("F:/Neighbor-joining-tree.newick")
t1 = dendrapply(t1,function(x) {
 if(is.leaf(x)) {
    attr(x,"height") = 0
  }
 x
})
hist_minor <- Heatmap(minor,column_title = "Statistics for a list of SNP.Frequency.minor",column_title_gp = gpar(fontsize = 15,fontface = "bold"),column_names_gp = gpar(fontsize = 10),row_title = "Genome Postion(bp)",row_title_gp = gpar(fontsize = 10),name = "Variant.Frequency",cluster_rows = FALSE,cluster_columns = t1,use_raster = TRUE,raster_resize_mat = max,right_annotation = ha,show_row_names = FALSE,col = cols,column_dend_height= unit(3,"cm"),#column_dend_height= unit(6,"cm")
                  border_gp = gpar(col = "black",lty = 2)
)

这很好用。所以对我来说,这一切都非常令人困惑!

解决方法

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

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

降级:

 PyJWT 

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

,

正如@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")