Describe the bug
Looks like we can only use True (boolean) to enable auto detect regional endpoint, rather than using "TryAutoDetect":
ATTEMPT_REGION_DISCOVERY = True # "TryAutoDetect"
However, Azure.Identity library is using environment variable AZURE_REGIONAL_AUTHORITY_NAME ("TryAutoDetect"), which can not be set to true.
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/identity/azure-identity/azure/identity/_internal/msal_credentials.py
Thus we cannot use auto detect with Azure.Identity library.
To Reproduce
Steps to reproduce the behavior - run following code in local machine, which trying to auto detect but it will fail as local machine is not AzureVM.
region = os.getenv("AZURE_REGIONAL_AUTHORITY_NAME")
if region is None or len(region) == 0:
print("set region to auto detect")
os.environ["AZURE_REGIONAL_AUTHORITY_NAME"] = "TryAutoDetect"
certificate_path = "your_local_cert.pfx"
certificate_credential = CertificateCredential(tenant_id='your tenant id',
client_id='your client id',
certificate_path=certificate_path,
password="your password",
send_certificate_chain=True)
token = certificate_credential.get_token('https://vault.azure.net/.default')
print(token)
Expected behavior
token should be acquired successfully.
What you see instead
CertificateCredential.get_token failed: Authentication failed: <urllib3.connection.HTTPSConnection object at 0x000001CAF0AE0D88>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
The MSAL Python version you are using
1.20.0
Additional context
Add any other context about the problem here.
Describe the bug
Looks like we can only use True (boolean) to enable auto detect regional endpoint, rather than using "TryAutoDetect":
ATTEMPT_REGION_DISCOVERY = True # "TryAutoDetect"
However, Azure.Identity library is using environment variable AZURE_REGIONAL_AUTHORITY_NAME ("TryAutoDetect"), which can not be set to true.
https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/identity/azure-identity/azure/identity/_internal/msal_credentials.py
Thus we cannot use auto detect with Azure.Identity library.
To Reproduce
Steps to reproduce the behavior - run following code in local machine, which trying to auto detect but it will fail as local machine is not AzureVM.
region = os.getenv("AZURE_REGIONAL_AUTHORITY_NAME")
if region is None or len(region) == 0:
print("set region to auto detect")
os.environ["AZURE_REGIONAL_AUTHORITY_NAME"] = "TryAutoDetect"
certificate_path = "your_local_cert.pfx"
certificate_credential = CertificateCredential(tenant_id='your tenant id',
client_id='your client id',
certificate_path=certificate_path,
password="your password",
send_certificate_chain=True)
token = certificate_credential.get_token('https://vault.azure.net/.default')
print(token)
Expected behavior
token should be acquired successfully.
What you see instead
CertificateCredential.get_token failed: Authentication failed: <urllib3.connection.HTTPSConnection object at 0x000001CAF0AE0D88>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed
The MSAL Python version you are using
1.20.0
Additional context
Add any other context about the problem here.