GithubHelp home page GithubHelp logo

github-event-processor-test's Issues

weird part 2

Thank you for your help.

The result on my machine as follows:

  • az account get-access-token --output json --resource https://vault.azure.net/ after az login (--use-device-code for my convenience) succeeded. The output is as follows.
{
  "accessToken": "<access_token>",
  "expiresOn": "<expires_on>",
  "subscription": "<subscription_id>",
  "tenant": "<tenant_id>",
  "tokenType": "Bearer"
}
  • However, pytest .\tests\test_learn_azure_key_vault.py after the above operation failed.

The main difference seems to be as follows:

  • before: DEBUG azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.

  • after: DEBUG azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.

My full log is as follows:

> pytest .\tests\test_learn_azure_key_vault.py
=============================================================== test session starts ===============================================================
platform win32 -- Python 3.9.6, pytest-7.2.2, pluggy-1.0.0
rootdir: <project_root_folder>\tests, configfile: pytest.ini
plugins: asyncio-0.20.3, cov-4.0.0, mock-3.10.0
asyncio: mode=strict
collected 1 item

tests\test_learn_azure_key_vault.py::TestClass::test_can_get_secret 
------------------------------------------------------------------ live log call ------------------------------------------------------------------
INFO     azure.identity._credentials.environment:environment.py:100 No environment configuration found.
INFO     azure.identity._credentials.managed_identity:managed_identity.py:83 ManagedIdentityCredential will use IMDS
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:549 Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
DEBUG    azure.identity._internal.decorators:decorators.py:54 EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
DEBUG    azure.identity._internal.get_token_mixin:get_token_mixin.py:85 ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DEBUG    azure.identity._credentials.chained:chained.py:86 DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
WARNING  azure.identity._credentials.chained:chained.py:100 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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
FAILED                                                                                                                                       [100%]

==================================================================== FAILURES ===================================================================== 
__________________________________________________________ TestClass.test_can_get_secret __________________________________________________________ 

self = <tests.test_learn_azure_key_vault.TestClass object at 0x000001679C168220>

    def test_can_get_secret(self):
        key_vault_name = "<key_vault_name>"
        vault_url = f"https://{key_vault_name}.vault.azure.net"

        credential = DefaultAzureCredential()
        client = SecretClient(vault_url=vault_url, credential=credential)

        secret_name = "<secret_name>"
>       key_vault_secret = client.get_secret(secret_name)

tests\test_learn_azure_key_vault.py:32:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv\lib\site-packages\azure\core\tracing\decorator.py:76: in wrapper_use_tracer
    return func(*args, **kwargs)
.venv\lib\site-packages\azure\keyvault\secrets\_client.py:72: in get_secret
    bundle = self._client.get_secret(
.venv\lib\site-packages\azure\keyvault\secrets\_generated\_operations_mixin.py:1640: in get_secret
    return mixin_instance.get_secret(vault_base_url, secret_name, secret_version, **kwargs)
.venv\lib\site-packages\azure\core\tracing\decorator.py:76: in wrapper_use_tracer
    return func(*args, **kwargs)
.venv\lib\site-packages\azure\keyvault\secrets\_generated\v7_4\operations\_key_vault_client_operations.py:760: in get_secret
    pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
.venv\lib\site-packages\azure\core\pipeline\_base.py:202: in run
    return first_node.send(pipeline_request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_redirect.py:156: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py:448: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_authentication.py:119: in send
    request_authorized = self.on_challenge(request, response)
.venv\lib\site-packages\azure\keyvault\secrets\_shared\challenge_auth_policy.py:112: in on_challenge
    self.authorize_request(request, scope, tenant_id=challenge.tenant_id)
.venv\lib\site-packages\azure\core\pipeline\policies\_authentication.py:99: in authorize_request
    self._token = self._credential.get_token(*scopes, **kwargs)
.venv\lib\site-packages\azure\identity\_credentials\default.py:168: in get_token
    return super(DefaultAzureCredential, self).get_token(*scopes, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <azure.identity._credentials.default.DefaultAzureCredential object at 0x000001679C168370>, scopes = ('https://vault.azure.net/.default',)    
kwargs = {'tenant_id': '<tenant_id>'}
history = [(<azure.identity._credentials.environment.EnvironmentCredential object at 0x000001679C168310>, 'EnvironmentCredential...s when creating the credential, or add "*" to additionally_allowed_tenants to allow acquiring tokens for any tenant.')]
credential = <azure.identity._credentials.shared_cache.SharedTokenCacheCredential object at 0x000001679C168880>
attempts = '\nAttempted credentials:\n\tEnvironmentCredential: EnvironmentCredential authentication unavailable. Environment vari...nts when creating the credential, or add "*" to additionally_allowed_tenants to allow acquiring tokens for any tenant.'
message = 'DefaultAzureCredential failed to retrieve a token from the included credentials.\nAttempted credentials:\n\tEnvironme...er to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.'

    def get_token(self, *scopes, **kwargs):  # pylint:disable=unused-argument
        # type: (*str, **Any) -> AccessToken
        """Request a token from each chained credential, in order, returning the first token received.

        This method is called automatically by Azure SDK clients.

        :param str scopes: desired scopes for the access token. This method requires at least one scope.
        :raises ~azure.core.exceptions.ClientAuthenticationError: no credential in the chain provided a token
        """
        within_credential_chain.set(True)
        history = []
        for credential in self.credentials:
            try:
                token = credential.get_token(*scopes, **kwargs)
                _LOGGER.info("%s acquired a token from %s", self.__class__.__name__, credential.__class__.__name__)
                self._successful_credential = credential
                return token
            except CredentialUnavailableError as ex:
                # credential didn't attempt authentication because it lacks required data or state -> continue
                history.append((credential, ex.message))
            except Exception as ex:  # pylint: disable=broad-except
                # credential failed to authenticate, or something unexpectedly raised -> break
                history.append((credential, str(ex)))
                _LOGGER.debug(
                    '%s.get_token failed: %s raised unexpected error "%s"',
                    self.__class__.__name__,
                    credential.__class__.__name__,
                    ex,
                    exc_info=True,
                )
                break

        within_credential_chain.set(False)
        attempts = _get_error_message(history)
        message = self.__class__.__name__ + " failed to retrieve a token from the included credentials." + attempts \
                  + "\nTo mitigate this issue, please refer to the troubleshooting guidelines here at " \
                    "https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot."
        _LOGGER.warning(message)
>       raise ClientAuthenticationError(message=message)
E       azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
E       Attempted credentials:
E               EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
E       Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
E               ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
E               SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
E       To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.

.venv\lib\site-packages\azure\identity\_credentials\chained.py:101: ClientAuthenticationError
-------------------------------------------------------------- Captured stdout call --------------------------------------------------------------- 
No environment configuration found.
ManagedIdentityCredential will use IMDS
Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
---------------------------------------------------------------- Captured log call ---------------------------------------------------------------- 
INFO     azure.identity._credentials.environment:environment.py:100 No environment configuration found.
INFO     azure.identity._credentials.managed_identity:managed_identity.py:83 ManagedIdentityCredential will use IMDS
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:549 Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
DEBUG    azure.identity._internal.decorators:decorators.py:54 EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
DEBUG    azure.identity._internal.get_token_mixin:get_token_mixin.py:85 ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DEBUG    azure.identity._credentials.chained:chained.py:86 DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
WARNING  azure.identity._credentials.chained:chained.py:100 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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
============================================================= short test summary info ============================================================= 
FAILED tests\test_learn_azure_key_vault.py::TestClass::test_can_get_secret - azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
================================================================ 1 failed in 0.93s ================================================================

[BUG]

All work and no play make Jim something something.

big desc

Thank you for your help.

The result on my machine as follows:

  • az account get-access-token --output json --resource https://vault.azure.net/ after az login (--use-device-code for my convenience) succeeded. The output is as follows.
{
  "accessToken": "<access_token>",
  "expiresOn": "<expires_on>",
  "subscription": "<subscription_id>",
  "tenant": "<tenant_id>",
  "tokenType": "Bearer"
}
  • However, pytest .\tests\test_learn_azure_key_vault.py after the above operation failed.

The main difference seems to be as follows:

  • before: DEBUG azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.

  • after: DEBUG azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.

My full log is as follows:

> pytest .\tests\test_learn_azure_key_vault.py
=============================================================== test session starts ===============================================================
platform win32 -- Python 3.9.6, pytest-7.2.2, pluggy-1.0.0
rootdir: <project_root_folder>\tests, configfile: pytest.ini
plugins: asyncio-0.20.3, cov-4.0.0, mock-3.10.0
asyncio: mode=strict
collected 1 item

tests\test_learn_azure_key_vault.py::TestClass::test_can_get_secret 
------------------------------------------------------------------ live log call ------------------------------------------------------------------
INFO     azure.identity._credentials.environment:environment.py:100 No environment configuration found.
INFO     azure.identity._credentials.managed_identity:managed_identity.py:83 ManagedIdentityCredential will use IMDS
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:549 Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
DEBUG    azure.identity._internal.decorators:decorators.py:54 EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
DEBUG    azure.identity._internal.get_token_mixin:get_token_mixin.py:85 ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DEBUG    azure.identity._credentials.chained:chained.py:86 DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
WARNING  azure.identity._credentials.chained:chained.py:100 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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
FAILED                                                                                                                                       [100%]

==================================================================== FAILURES ===================================================================== 
__________________________________________________________ TestClass.test_can_get_secret __________________________________________________________ 

self = <tests.test_learn_azure_key_vault.TestClass object at 0x000001679C168220>

    def test_can_get_secret(self):
        key_vault_name = "<key_vault_name>"
        vault_url = f"https://{key_vault_name}.vault.azure.net"

        credential = DefaultAzureCredential()
        client = SecretClient(vault_url=vault_url, credential=credential)

        secret_name = "<secret_name>"
>       key_vault_secret = client.get_secret(secret_name)

tests\test_learn_azure_key_vault.py:32:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv\lib\site-packages\azure\core\tracing\decorator.py:76: in wrapper_use_tracer
    return func(*args, **kwargs)
.venv\lib\site-packages\azure\keyvault\secrets\_client.py:72: in get_secret
    bundle = self._client.get_secret(
.venv\lib\site-packages\azure\keyvault\secrets\_generated\_operations_mixin.py:1640: in get_secret
    return mixin_instance.get_secret(vault_base_url, secret_name, secret_version, **kwargs)
.venv\lib\site-packages\azure\core\tracing\decorator.py:76: in wrapper_use_tracer
    return func(*args, **kwargs)
.venv\lib\site-packages\azure\keyvault\secrets\_generated\v7_4\operations\_key_vault_client_operations.py:760: in get_secret
    pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
.venv\lib\site-packages\azure\core\pipeline\_base.py:202: in run
    return first_node.send(pipeline_request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_redirect.py:156: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py:448: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_authentication.py:119: in send
    request_authorized = self.on_challenge(request, response)
.venv\lib\site-packages\azure\keyvault\secrets\_shared\challenge_auth_policy.py:112: in on_challenge
    self.authorize_request(request, scope, tenant_id=challenge.tenant_id)
.venv\lib\site-packages\azure\core\pipeline\policies\_authentication.py:99: in authorize_request
    self._token = self._credential.get_token(*scopes, **kwargs)
.venv\lib\site-packages\azure\identity\_credentials\default.py:168: in get_token
    return super(DefaultAzureCredential, self).get_token(*scopes, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <azure.identity._credentials.default.DefaultAzureCredential object at 0x000001679C168370>, scopes = ('https://vault.azure.net/.default',)    
kwargs = {'tenant_id': '<tenant_id>'}
history = [(<azure.identity._credentials.environment.EnvironmentCredential object at 0x000001679C168310>, 'EnvironmentCredential...s when creating the credential, or add "*" to additionally_allowed_tenants to allow acquiring tokens for any tenant.')]
credential = <azure.identity._credentials.shared_cache.SharedTokenCacheCredential object at 0x000001679C168880>
attempts = '\nAttempted credentials:\n\tEnvironmentCredential: EnvironmentCredential authentication unavailable. Environment vari...nts when creating the credential, or add "*" to additionally_allowed_tenants to allow acquiring tokens for any tenant.'
message = 'DefaultAzureCredential failed to retrieve a token from the included credentials.\nAttempted credentials:\n\tEnvironme...er to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.'

    def get_token(self, *scopes, **kwargs):  # pylint:disable=unused-argument
        # type: (*str, **Any) -> AccessToken
        """Request a token from each chained credential, in order, returning the first token received.

        This method is called automatically by Azure SDK clients.

        :param str scopes: desired scopes for the access token. This method requires at least one scope.
        :raises ~azure.core.exceptions.ClientAuthenticationError: no credential in the chain provided a token
        """
        within_credential_chain.set(True)
        history = []
        for credential in self.credentials:
            try:
                token = credential.get_token(*scopes, **kwargs)
                _LOGGER.info("%s acquired a token from %s", self.__class__.__name__, credential.__class__.__name__)
                self._successful_credential = credential
                return token
            except CredentialUnavailableError as ex:
                # credential didn't attempt authentication because it lacks required data or state -> continue
                history.append((credential, ex.message))
            except Exception as ex:  # pylint: disable=broad-except
                # credential failed to authenticate, or something unexpectedly raised -> break
                history.append((credential, str(ex)))
                _LOGGER.debug(
                    '%s.get_token failed: %s raised unexpected error "%s"',
                    self.__class__.__name__,
                    credential.__class__.__name__,
                    ex,
                    exc_info=True,
                )
                break

        within_credential_chain.set(False)
        attempts = _get_error_message(history)
        message = self.__class__.__name__ + " failed to retrieve a token from the included credentials." + attempts \
                  + "\nTo mitigate this issue, please refer to the troubleshooting guidelines here at " \
                    "https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot."
        _LOGGER.warning(message)
>       raise ClientAuthenticationError(message=message)
E       azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
E       Attempted credentials:
E               EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
E       Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
E               ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
E               SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
E       To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.

.venv\lib\site-packages\azure\identity\_credentials\chained.py:101: ClientAuthenticationError
-------------------------------------------------------------- Captured stdout call --------------------------------------------------------------- 
No environment configuration found.
ManagedIdentityCredential will use IMDS
Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
---------------------------------------------------------------- Captured log call ---------------------------------------------------------------- 
INFO     azure.identity._credentials.environment:environment.py:100 No environment configuration found.
INFO     azure.identity._credentials.managed_identity:managed_identity.py:83 ManagedIdentityCredential will use IMDS
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:549 Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
DEBUG    azure.identity._internal.decorators:decorators.py:54 EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
DEBUG    azure.identity._internal.get_token_mixin:get_token_mixin.py:85 ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DEBUG    azure.identity._credentials.chained:chained.py:86 DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
WARNING  azure.identity._credentials.chained:chained.py:100 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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
============================================================= short test summary info ============================================================= 
FAILED tests\test_learn_azure_key_vault.py::TestClass::test_can_get_secret - azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
================================================================ 1 failed in 0.93s ================================================================

new issue with long description

Thank you for your help.

The result on my machine as follows:

  • az account get-access-token --output json --resource https://vault.azure.net/ after az login (--use-device-code for my convenience) succeeded. The output is as follows.
{
  "accessToken": "<access_token>",
  "expiresOn": "<expires_on>",
  "subscription": "<subscription_id>",
  "tenant": "<tenant_id>",
  "tokenType": "Bearer"
}
  • However, pytest .\tests\test_learn_azure_key_vault.py after the above operation failed.

The main difference seems to be as follows:

  • before: DEBUG azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: SharedTokenCacheCredential authentication unavailable. No accounts were found in the cache.

  • after: DEBUG azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.

My full log is as follows:

> pytest .\tests\test_learn_azure_key_vault.py
=============================================================== test session starts ===============================================================
platform win32 -- Python 3.9.6, pytest-7.2.2, pluggy-1.0.0
rootdir: <project_root_folder>\tests, configfile: pytest.ini
plugins: asyncio-0.20.3, cov-4.0.0, mock-3.10.0
asyncio: mode=strict
collected 1 item

tests\test_learn_azure_key_vault.py::TestClass::test_can_get_secret 
------------------------------------------------------------------ live log call ------------------------------------------------------------------
INFO     azure.identity._credentials.environment:environment.py:100 No environment configuration found.
INFO     azure.identity._credentials.managed_identity:managed_identity.py:83 ManagedIdentityCredential will use IMDS
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:549 Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
DEBUG    azure.identity._internal.decorators:decorators.py:54 EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
DEBUG    azure.identity._internal.get_token_mixin:get_token_mixin.py:85 ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DEBUG    azure.identity._credentials.chained:chained.py:86 DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
WARNING  azure.identity._credentials.chained:chained.py:100 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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
FAILED                                                                                                                                       [100%]

==================================================================== FAILURES ===================================================================== 
__________________________________________________________ TestClass.test_can_get_secret __________________________________________________________ 

self = <tests.test_learn_azure_key_vault.TestClass object at 0x000001679C168220>

    def test_can_get_secret(self):
        key_vault_name = "<key_vault_name>"
        vault_url = f"https://{key_vault_name}.vault.azure.net"

        credential = DefaultAzureCredential()
        client = SecretClient(vault_url=vault_url, credential=credential)

        secret_name = "<secret_name>"
>       key_vault_secret = client.get_secret(secret_name)

tests\test_learn_azure_key_vault.py:32:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.venv\lib\site-packages\azure\core\tracing\decorator.py:76: in wrapper_use_tracer
    return func(*args, **kwargs)
.venv\lib\site-packages\azure\keyvault\secrets\_client.py:72: in get_secret
    bundle = self._client.get_secret(
.venv\lib\site-packages\azure\keyvault\secrets\_generated\_operations_mixin.py:1640: in get_secret
    return mixin_instance.get_secret(vault_base_url, secret_name, secret_version, **kwargs)
.venv\lib\site-packages\azure\core\tracing\decorator.py:76: in wrapper_use_tracer
    return func(*args, **kwargs)
.venv\lib\site-packages\azure\keyvault\secrets\_generated\v7_4\operations\_key_vault_client_operations.py:760: in get_secret
    pipeline_response: PipelineResponse = self._client._pipeline.run(  # pylint: disable=protected-access
.venv\lib\site-packages\azure\core\pipeline\_base.py:202: in run
    return first_node.send(pipeline_request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\_base.py:70: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_redirect.py:156: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py:448: in send
    response = self.next.send(request)
.venv\lib\site-packages\azure\core\pipeline\policies\_authentication.py:119: in send
    request_authorized = self.on_challenge(request, response)
.venv\lib\site-packages\azure\keyvault\secrets\_shared\challenge_auth_policy.py:112: in on_challenge
    self.authorize_request(request, scope, tenant_id=challenge.tenant_id)
.venv\lib\site-packages\azure\core\pipeline\policies\_authentication.py:99: in authorize_request
    self._token = self._credential.get_token(*scopes, **kwargs)
.venv\lib\site-packages\azure\identity\_credentials\default.py:168: in get_token
    return super(DefaultAzureCredential, self).get_token(*scopes, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <azure.identity._credentials.default.DefaultAzureCredential object at 0x000001679C168370>, scopes = ('https://vault.azure.net/.default',)    
kwargs = {'tenant_id': '<tenant_id>'}
history = [(<azure.identity._credentials.environment.EnvironmentCredential object at 0x000001679C168310>, 'EnvironmentCredential...s when creating the credential, or add "*" to additionally_allowed_tenants to allow acquiring tokens for any tenant.')]
credential = <azure.identity._credentials.shared_cache.SharedTokenCacheCredential object at 0x000001679C168880>
attempts = '\nAttempted credentials:\n\tEnvironmentCredential: EnvironmentCredential authentication unavailable. Environment vari...nts when creating the credential, or add "*" to additionally_allowed_tenants to allow acquiring tokens for any tenant.'
message = 'DefaultAzureCredential failed to retrieve a token from the included credentials.\nAttempted credentials:\n\tEnvironme...er to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.'

    def get_token(self, *scopes, **kwargs):  # pylint:disable=unused-argument
        # type: (*str, **Any) -> AccessToken
        """Request a token from each chained credential, in order, returning the first token received.

        This method is called automatically by Azure SDK clients.

        :param str scopes: desired scopes for the access token. This method requires at least one scope.
        :raises ~azure.core.exceptions.ClientAuthenticationError: no credential in the chain provided a token
        """
        within_credential_chain.set(True)
        history = []
        for credential in self.credentials:
            try:
                token = credential.get_token(*scopes, **kwargs)
                _LOGGER.info("%s acquired a token from %s", self.__class__.__name__, credential.__class__.__name__)
                self._successful_credential = credential
                return token
            except CredentialUnavailableError as ex:
                # credential didn't attempt authentication because it lacks required data or state -> continue
                history.append((credential, ex.message))
            except Exception as ex:  # pylint: disable=broad-except
                # credential failed to authenticate, or something unexpectedly raised -> break
                history.append((credential, str(ex)))
                _LOGGER.debug(
                    '%s.get_token failed: %s raised unexpected error "%s"',
                    self.__class__.__name__,
                    credential.__class__.__name__,
                    ex,
                    exc_info=True,
                )
                break

        within_credential_chain.set(False)
        attempts = _get_error_message(history)
        message = self.__class__.__name__ + " failed to retrieve a token from the included credentials." + attempts \
                  + "\nTo mitigate this issue, please refer to the troubleshooting guidelines here at " \
                    "https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot."
        _LOGGER.warning(message)
>       raise ClientAuthenticationError(message=message)
E       azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
E       Attempted credentials:
E               EnvironmentCredential: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
E       Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
E               ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
E               SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
E       To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.

.venv\lib\site-packages\azure\identity\_credentials\chained.py:101: ClientAuthenticationError
-------------------------------------------------------------- Captured stdout call --------------------------------------------------------------- 
No environment configuration found.
ManagedIdentityCredential will use IMDS
Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
---------------------------------------------------------------- Captured log call ---------------------------------------------------------------- 
INFO     azure.identity._credentials.environment:environment.py:100 No environment configuration found.
INFO     azure.identity._credentials.managed_identity:managed_identity.py:83 ManagedIdentityCredential will use IMDS
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'https://<key_vault_name>.vault.azure.net/secrets/<secret_name>/?api-version=REDACTED'
Request method: 'GET'
Request headers:
    'Accept': 'application/json'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'User-Agent': 'azsdk-python-keyvault-secrets/4.7.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:549 Response status: 401
Response headers:
    'Cache-Control': 'no-cache'
    'Pragma': 'no-cache'
    'Content-Length': '97'
    'Content-Type': 'application/json; charset=utf-8'
    'Expires': '-1'
    'WWW-Authenticate': 'Bearer authorization="https://login.microsoftonline.com/<tenant_id>", resource="https://vault.azure.net"'
    'x-ms-keyvault-region': 'japaneast'
    'x-ms-client-request-id': '<x-ms-client-request-id>'
    'x-ms-request-id': '<x-ms-request-id>'
    'x-ms-keyvault-service-version': '1.9.804.1'
    'x-ms-keyvault-network-info': 'conn_type=Ipv4;addr=<x-ms-keyvault-ip-address>;act_addr_fam=InterNetwork;'
    'X-Content-Type-Options': 'REDACTED'
    'Strict-Transport-Security': 'REDACTED'
    'Date': 'Wed, 31 May 2023 04:38:45 GMT'
DEBUG    azure.identity._internal.decorators:decorators.py:54 EnvironmentCredential.get_token failed: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\environment.py", line 134, in get_token
    raise CredentialUnavailableError(message=message)
azure.identity._exceptions.CredentialUnavailableError: EnvironmentCredential authentication unavailable. Environment variables are not fully configured.
Visit https://aka.ms/azsdk/python/identity/environmentcredential/troubleshoot to troubleshoot.this issue.
INFO     azure.core.pipeline.policies.http_logging_policy:_universal.py:513 Request URL: 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=REDACTED&resource=REDACTED'
Request method: 'GET'
Request headers:
    'User-Agent': 'azsdk-python-identity/1.12.0 Python/3.9.6 (Windows-10-10.0.22621-SP0)'
No body was attached to the request
DEBUG    azure.identity._internal.get_token_mixin:get_token_mixin.py:85 ImdsCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 ManagedIdentityCredential.get_token failed: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 74, in _request_token
    self._client.request_token(*scopes, connection_timeout=0.3, retry_total=0)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\managed_identity_client.py", line 119, in request_token
    response = self._pipeline.run(request, retry_on_methods=[request.method], **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 202, in run
    return first_node.send(pipeline_request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 470, in send   
    raise err
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\policies\_retry.py", line 448, in send   
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 70, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\_base.py", line 101, in send
    self._sender.send(request.http_request, **request.context.options),
  File "<project_root_folder>\.venv\lib\site-packages\azure\core\pipeline\transport\_requests_basic.py", line 364, in send
    raise error
azure.core.exceptions.ServiceRequestError: <urllib3.connection.HTTPConnection object at 0x000001679C3D0A60>: Failed to establish a new connection: [WinError 10051] tried to execute the socket operation at unreachable network.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\managed_identity.py", line 115, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\get_token_mixin.py", line 70, in get_token
    token = self._request_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\imds.py", line 85, in _request_token
    six.raise_from(CredentialUnavailableError(self._error_message), ex)
  File "<string>", line 3, in raise_from
azure.identity._exceptions.CredentialUnavailableError: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.    
DEBUG    azure.identity._internal.decorators:decorators.py:54 SharedTokenCacheCredential.get_token failed: The current credential is not configured to acquire tokens for tenant <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.
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
DEBUG    azure.identity._credentials.chained:chained.py:86 DefaultAzureCredential.get_token failed: SharedTokenCacheCredential raised unexpected error "The current credential is not configured to acquire tokens for tenant <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."
Traceback (most recent call last):
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\chained.py", line 76, in get_token
    token = credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\decorators.py", line 32, in wrapper 
    token = fn(*args, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 75, in get_token
    return self._credential.get_token(*scopes, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_credentials\shared_cache.py", line 117, in get_token
    token = self._client.obtain_token_by_refresh_token(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client.py", line 73, in obtain_token_by_refresh_token
    request = self._get_refresh_token_request(scopes, refresh_token, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 254, in _get_refresh_token_request
    request = self._post(data, **kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 285, in _post
    url = self._get_token_url(**kwargs)
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\aad_client_base.py", line 276, in _get_token_url
    tenant = resolve_tenant(
  File "<project_root_folder>\.venv\lib\site-packages\azure\identity\_internal\utils.py", line 74, in resolve_tenant
    raise ClientAuthenticationError(
azure.core.exceptions.ClientAuthenticationError: The current credential is not configured to acquire tokens for tenant <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.
WARNING  azure.identity._credentials.chained:chained.py:100 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/troubleshoot to troubleshoot.this issue.
        ManagedIdentityCredential: ManagedIdentityCredential authentication unavailable, no response from the IMDS endpoint.
        SharedTokenCacheCredential: The current credential is not configured to acquire tokens for tenant <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.
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/defaultazurecredential/troubleshoot.
============================================================= short test summary info ============================================================= 
FAILED tests\test_learn_azure_key_vault.py::TestClass::test_can_get_secret - azure.core.exceptions.ClientAuthenticationError: DefaultAzureCredential failed to retrieve a token from the included credentials.
================================================================ 1 failed in 0.93s ================================================================

[FakeIssueForTesting][FEATURE REQ] Azure Function EventHub allow passing of the PartitionKey in the EventData ctor

Library name

Azure.Messaging.EventHubs

Please describe the feature.

It would be great if could pass a PartitionKey while creating a new EventData object.

This would allow the use of user defined partition keys when adding message via the EventHub output binding's IAsyncCollector.AddAsync method.

This is desirable over the use of EventHubProducerClient.SendAsync due to the fact that IAsyncCollector.AddAsync will queue the message and batch behind the scenes in parallel, whereas EventHubProducerClient.SendAsync needs to be awaited on each send of a single message or a batch.

The two mechanisms behave quite differently from each other and we've seen large performance gains while using the IAsyncCollector and IAsyncCollector.Flush compared to EventHubProducerClient.SendAsync.

cs\nIAsyncCollector collector = from output binding\nEventData message = new EventData(data);\nawait collector.AddAsync(message); <-- returns immediately and is sent in parallel\n...\nmore stuff\n...\nawait collector.Flush(); <-- waits for remaining messages to send\n\nvs\ncs\nEventHubProducerClient client = from output binding\nEventData message = new EventData(data);\nawait client.SendAsync(message); <-- waits for the send operation before returning\n

This is similar to some of the comments in Azure/azure-sdk-for-net#28245 but it's not the same as the issue itself.

We've done some testing using the EventHubsModelFactory.EventData testing method and verified the partition key when set via this method appears to be used correctly by IAsyncCollector and the events do in fact send and arrive downstream in the correct batches with the set partition.

Clearly, we can't use this testing and mocking method for production though.

Or maybe there's another way to use the IAsyncCollector?

Thanks :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.