azure-sdk-for-python: [Tables] Delete Entity Returning Unauthorized, Query Entities Not

  • Package Name: azure-data-tables (reproducable in azure-cosmosdb-tables)
  • Package Version: 12.0.0b3
  • Operating System: Windows 10
  • Python Version: 3.8.6

Describe the bug After creating a TableClient from azure.data.tables.aio, a call to table_client.query_entities is successful. Just a few lines later, a call to table_client.delete_entity is not, and returns a ClientAutheniticationError: Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.

I’ve tried this with azure.cosmosdb.table as well: Using similar calls, the query call is successful, but the delete call returns an AzureSigningError: Incorrect padding.

I have verified that the key is 88 characters long, ends with ==, and is DIRECTLY copied from the storage account in question. It obviously works for the query_entities call.

To Reproduce Steps to reproduce the behavior:

  1. Create an Azure Storage Account, add a table to it, and name the table “Locator”. Add a few entities with a column called LocatorHash, with any string value you like.
  2. Run the following code:
    from azure.data.tables.aio import TableClient
    from azure.core import MatchingConditions

    table_name = 'Locator'
    email_hash = '...' #Can be any string value contained in the LocatorHash column
    table_client = TableClient(account_url='https://<YOURACCOUNTNAME>.table.core.windows.net', table_name=table_name, credential=os.environ['STORAGE_ACCOUNT_ACCESS_KEY'])
    async with table_client:
        locator_entities = table_client.query_entities(filter=f"LocatorHash eq '{email_hash}'")
        coroutines = []
        async for locator_entity in locator_entities:
            logging.info(f"Deleting record: {locator_entity}")
            # error occurs on this line
            await table_client.delete_entity(row_key=locator_entity['RowKey'], partition_key=locator_entity['PartitionKey'], etag=locator_entity['_metadata']['etag'], match_condition=MatchConditions.Unconditionally)

Expected behavior Entities are deleted rather than receiving an AuthError.

Screenshots

When using azure.data.tables.aio image

When using azure.cosmosdb.table – note, had to edit code to be synchronous image

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 22 (12 by maintainers)

Most upvoted comments

@seankane-msft I hate that this is a bug for you guys, but it is so validating to know that I’m not crazy!

@sejohnson-at-griffis I was able to confirm what @annatisch hypothesized. Changing my RowKey to be foo@bar.com would fail on a delete. It also fails on a upsert_entity call, but will succeed on a create_entity. The get_entity was unsuccessful as well.