get workspace failed azuremlsdk - AuthenticationException

863 views Asked by At

I have created a workspace in our azure environment and try to run this code:

library(azuremlsdk)

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

Some interactive authenticator opens in my browser, which I think is intended behaviour as I have no tenantdid. However, I get this:

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'"
    }
}

I also tried:

az login

This works fine. So for me all this is very confusing!

2

There are 2 answers

1
cs0815 On BEST ANSWER

So I tried the same in Python and had a similar error and came across this:

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

Downgrading:

 PyJWT 

helped. The bizarre world of open source and its web of interdependencies!

0
Alberto Martín Pérez On

As @cs0815 mentioned, this Github issue helped me solve this issue: https://github.com/Azure/azure-sdk-for-python/issues/16035

What I did to solve this issue?

1. Check package versions

I had azure-core version 1.15.0 when I run the following command:

pip show azure-core

The PyJWT I had was 2.1.0 when I run this command:

pip show PyJWT

2. Downgrade PyJWT to 1.7.1

To do so, I run this command:

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

3. Check Workspace connection

I run this Python script to connect to my Azure Machine Learning Workspace:

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")