Reading credentials from azure failed: DefaultAzureCredential failed to retrieve a token from the included credentials.

Yedukondalu Mammu 0 Reputation points
2024-05-28T06:16:03.5266667+00:00

0

I'm trying read azure default credentials but fails with following error


DefaultAzureCredential failed to retrieve a token from the included credentials.
04:54:12.161
lrr-data-service-perf-green-x
Attempted credentials:
   EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
   ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable. The requested identity has not been assigned to this resource.
   SharedTokenCacheCredential: Shared token cache unavailable
   VisualStudioCodeCredential: Failed to get Azure user details from Visual Studio Code.
   AzureCliCredential: Azure CLI not found on path
   AzurePowerShellCredential: PowerShell is not installed
DefaultAzureCredential failed to retrieve a token 

Can you help resolving the issue?

And this is how we get the creds.


def __prepare_postgre_db_url(cfg):
    postgres_server_resource_id = cfg["postgres_server_resource_id"]
    db = Vault.get_postgres_creds(postgres_server_resource_id)
    return (
        f"postgresql://{db['username']}:{db['password']}@{db['hostname']}:5432/postgres"
    )

Azure Database for PostgreSQL
Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
324 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Oury Ba-MSFT 17,631 Reputation points Microsoft Employee
    2024-06-06T21:14:12.7433333+00:00

    @Yedukondalu Mammu

    I was able to deploy my resource into azure by following this doc.

    https://video2.skills-academy.com/en-us/azure/postgresql/flexible-server/quickstart-create-server-python-sdk?tabs=PythonSDK

    Creating environments: https://code.visualstudio.com/docs/python/environments

    Using the Create Environment command

    To create local environments in VS Code using virtual environments or Anaconda, you can follow these steps: open the Command Palette (Ctrl+Shift+P), search for the Python: Create Environment command, and select it.

    The command presents a list of environment types: Venv or Conda.

    Create Environment dropdown

    If you are creating an environment using Venv, the command presents a list of interpreters that can be used as a base for the new virtual environment.

    Virtual environment interpreter selection

    If you are creating an environment using Conda, the command presents a list of Python versions that can be used for your project.

    Conda environment Python version selection

    You will need to install the following packages

    pip install azure-mgmt-resource

    pip install azure-identity

    pip install azure-mgmt-rdbms

    User's image

    User's image

    User's image

    Please let me know if you are still facing issues.

    Regards,

    Oury