Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python getting results from Azure Storage Table with azure-data-tables

I am trying to query an Azure storage table to get all rows to turn into a table on a web site, however I cannot get the entries from the table, I get the same error every time "azure.core.exceptions.HttpResponseError: The requested operation is not implemented on the specified resource."

For code I am following the examples here and it is not working as expected.

from azure.data.tables import TableServiceClient
from azure.core.credentials import AzureNamedKeyCredential

def read_storage_table():
    credential = AzureNamedKeyCredential(os.environ["AZ_STORAGE_ACCOUNT"], os.environ["AZ_STORAGE_KEY"])
    service = TableServiceClient(endpoint=os.environ["AZ_STORAGE_ENDPOINT"], credential=credential)
    client = service.get_table_client(table_name=os.environ["AZ_STORAGE_TABLE"])
    entities = client.query_entities(query_filter="PartitionKey eq 'tasksSeattle'")
    client.close()
    service.close()

    return entities

Then calling the function.

table = read_storage_table()
for record in table:
    for key in record.keys():
        print("Key: {}, Value: {}".format(key, record[key]))

And that returns:

Traceback (most recent call last):
  File "C:\Program Files\Python310\Lib\site-packages\azure\data\tables\_models.py", line 363, in _get_next_cb
    return self._command(
  File "C:\Program Files\Python310\Lib\site-packages\azure\data\tables\_generated\operations\_table_operations.py", line 386, in query_entities
    raise HttpResponseError(response=response, model=error) 
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Not Implemented'
Content: {"odata.error":{"code":"NotImplemented","message":{"lang":"en-US","value":"The requested operation is not implemented on the specified resource.\nRequestId:cd29feda-1002-006b-679c-3d39e8000000\nTime:2022-03-22T03:27:00.5993216Z"}}}

Using a similar function I am able to write to the table. But even trying entities = client.list_entities() I get the same error. I'm at a loss.

like image 414
KrunkFu Avatar asked Oct 26 '25 07:10

KrunkFu


1 Answers

KrunkFu thank you for identifying and sharing the solution here. Posting the same into answer section to help other community members.

replacing https://<accountname>.table.core.windows.net/<table>, with https://<accountname>.table.core.windows.net to the query solved the issue

like image 79
Madhuraj Vadde Avatar answered Oct 29 '25 09:10

Madhuraj Vadde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!