I am new on Azure cloud and using my personal account for Microsoft Azure Cloud. I have installed Azure ML Client library for Python using this resource.
I am trying to connect to Azure Machine Learning client on my local computer based on Ubuntu 22.04, using MLClient
When I try to use DefaultAzureCredential
or even InteractiveBrowserCredential
from azure.identity
for MLClient
, I receive this error:
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.
Here is the code snippet I am using:
from azure.ai.ml import MLClient
from azure.identity import InteractiveBrowserCredential, DefaultAzureCredential
ml_client = MLClient(
InteractiveBrowserCredential(),
subscription_id,
resource_group,
workspace
)
I have taken subscription_id
, resource_group
and workspace
from the default config.json
. Using InteractiveBrowserCredential
, I am directed to browser for authentication, which is successful but then it gets stuck on the above error.
I have also used DefaultAzureCredential
, while setting environment variables AZURE_TENANT_ID
, AZURE_CLIENT_ID
and AZURE_CLIENT_SECRET
using export AZURE_TENANT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
, but the end result is always the same error.
I have gone through solution-1, and solution-2, but these are not related to my case, as per my understanding.
Regarding this official documentation, it talks about organization, which I doubt I am not a part of, since I am using my personal account.
1
The issue is that you are trying to access resources in a different tenant, or your resources have been moved to a different tenant. The account you are logging in with should be registered.
Follow this stack solution for help.
Also, try using ClientSecretCredential
instead of setting AZURE_TENANT_ID
, AZURE_CLIENT_ID
, and AZURE_CLIENT_SECRET
environment variables.
Use the code below:
ml_client = MLClient(
ClientSecretCredential(client_id="client_id", tenant_id="tenant_id", client_secret="secret"),
"subscription_id",
"resource_grp",
"jgsml"
)
If the error persists, I would suggest restarting the kernel and checking again.