A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/Azure/azure-sdk-for-python/issues/27410 below:

'ClientAuthenticationError' object has no attribute 'error_code' · Issue #27410 · Azure/azure-sdk-for-python · GitHub

Packages: azure-data-tables==12.4.1, azure-identity==1.12.0
Operating System: Windows 10
Python Version: 3.10.4

Describe the bug
When DefaultAzureCredential() fails to retrieve a token with azure.data.tables.aio.TableServiceClient().create_table_if_not_exists() the error does not appear to be handled properly.

Observed error message:
'ClientAuthenticationError' object has no attribute 'error_code'

Expected error message (or similar):

azure.core.exceptions.ClientAuthenticationError: ChainedTokenCredential 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.
VisualStudioCodeCredential: Failed to get Azure user details from Visual Studio Code.
AzureCliCredential: Failed to execute 'cmd'
AzurePowerShellCredential: Failed to execute "cmd".
To mitigate this issue, please refer to the troubleshooting guidelines here at https://aka.ms/azsdk/python/identity/powershellcredential/troubleshoot.

Reproducible Example:
Run code in environment where DefaultAzureCredential() will fail.

import asyncio

class SampleTablesQuery(object):
    def __init__(self):
        self.account = "myaccount"
        self.table = "TestInsert"

    async def test_create_table(self):
        from azure.identity.aio import DefaultAzureCredential
        from azure.data.tables.aio import TableServiceClient
        credential = DefaultAzureCredential(
            exclude_shared_token_cache_credential=True,
            exclude_powershell_credential=True,
            exclude_cli_credential=True)
        async with credential:
            table_service_client = TableServiceClient(
                endpoint="https://{}.table.core.windows.net/".format(
                    self.account),
                credential=credential)
            async with table_service_client:
                await table_service_client.create_table_if_not_exists(table_name=self.table)


async def main():
    stq = SampleTablesQuery()
    try:
        await stq.test_create_table()
    except Exception as e:
        print(e)

if __name__ == "__main__":
    asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
    asyncio.run(main())


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4