DefaultAzureCredential failed to retrieve a token from the included credentials in VSCode Python SDK v2

Daniel Lazaro 0 Reputation points
2024-12-28T00:19:33.4566667+00:00

Hi, and thank you in advanced for your help. I am new to Azure and been stuck with this all day. I am working in VSCode, with the pertinent extensions for Azure (they all seem to work fine as I can authenticate/login in them and see all the resources).

I am using Python SDK v2, and Azure CLI version 2.65. I am using a Conda environment with all the libraries installed.

I can't get rid of this error I get when I try to create an MLClient and authenticate into the workspace in order to access the jobs in Azure Machine Learning and download a model.

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

# Create an MLClient instance
ml_client = MLClient(
    DefaultAzureCredential(),
    subscription_id,
    resource_group,
    workspace_name

I have already installed the Azure Extensions, and Authenticate via the Azure Developer CLI, everything looks fine until I run:

(User's image

)

automl_job = ml_client.jobs.get(name=job_name)

I get this error:

DefaultAzureCredential failed to retrieve a token from the included credentials. Attempted credentials: EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured. Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshootto troubleshoot this issue. ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint. SharedTokenCacheCredential: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache. AzureCliCredential: Azure CLI not found on path AzurePowerShellCredential: Az.Account module >= 2.2.0 is not installed AzureDeveloperCliCredential: Azure Developer CLI could not be found. Please visithttps://aka.ms/azure-devfor installation instructions and then,once installed, authenticate to your Azure account using 'azd auth login'. To mitigate this issue, please refer to the troubleshooting guidelines here athttps://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,316 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anna Xiu-MSFT 30,476 Reputation points Microsoft Vendor
    2024-12-30T02:26:04.98+00:00

    Hi @Daniel Lazaro

    Welcome to Microsoft Q&A! 

    Your issue is related to Visual Studio Code, I recommend you post it to the GitHub-vscode forum where you would get support for this product.

    Thanks for your understanding. 

    Sincerely,

    Anna


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".  Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

     

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.