[Python] Azure still using my old tenant ID for authentication

Discussão em 'Python' iniciado por Stack, Fevereiro 12, 2025.

  1. Stack

    Stack Membro Participativo

    I had been using my Microsoft account for Azure and successfully authenticated using its credentials. I also created an Entra app in that account and set up permissions for it.

    Recently, I created a new Azure account with a different email and set up a new Entra app there. I want to switch completely to this new Azure account.

    In my Python app, I'm using the Azure SDK with DefaultCredentials() and have set the following environment variables to point to the new account:

    • AZURE_TENANT_ID
    • AZURE_CLIENT_ID
    • AZURE_CLIENT_SECRET

    When I use the old account's credentials, everything works fine, and I'm able to upload blobs to my storage account. However, when I switch to the new account by updating the environment variables, Azure still tries to use the old AZURE_TENANT_ID, resulting in an authorization error:


    azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant {my_old_tenant_id}. To enable acquiring tokens for this tenant add it to the additionally_allowed_tenants when creating the credential, or add "*" to additionally_allowed_tenants to allow acquiring tokens for any tenant.
    ​

    Tried:

    1. Removing my old tenant_id from my code completely.
    2. Removed ~/.azure folder.
    3. Hardcoded my new tenant_id in the azure code.

    Continue reading...

Compartilhe esta Página