0

Data:

In [66]: list(a.table_service.query_entities('Watchlists',filter="RowKey eq '106619222' "))[-1]
Out[66]: 
{'PartitionKey': '2019-01-24',
 'RowKey': '106619222',
 'Timestamp': datetime.datetime(2019, 1, 24, 16, 36, 45, 474017, tzinfo=tzutc()),
 'avg_vol': 194.3305,
 'ftw_high': 14.68,
 'sell_price_high': 15.5608,
 'sell_price_low': 13.7992,
 'symbol': 'ACRE',
 'conId': 106619222,
 'date': datetime.datetime(2019, 1, 24, 0, 0, tzinfo=tzutc()),
 'is_breakout': False,
 'order_status': 'N/A',
 'last_price': nan,
 'last_volume': nan,
 'etag': 'W/"datetime\'2019-01-24T16%3A36%3A45.4740173Z\'"'}

In [67]: {k:(v.type,v.value) for k,v in entity.items()}
Out[67]: 
{'PartitionKey': ('Edm.String', '2019-01-24'),
 'RowKey': ('Edm.String', '106619222'),
 'Timestamp': ('Edm.DateTime',
  Timestamp('2019-01-24 16:36:45.474017+0000', tz='UTC')),
 'avg_vol': ('Edm.Double', 194.3305),
 'conId': ('Edm.Int64', 106619222),
 'date': ('Edm.DateTime', Timestamp('2019-01-24 00:00:00+0000', tz='UTC')),
 'ftw_high': ('Edm.Double', 14.68),
 'is_breakout': ('Edm.Boolean', False),
 'last_price': ('Edm.Double', 14.04),
 'last_volume': ('Edm.Double', 302.0),
 'order_status': ('Edm.String', 'N/A'),
 'sell_price_high': ('Edm.Double', 15.5608),
 'sell_price_low': ('Edm.Double', 13.7992),
 'symbol': ('Edm.String', 'ACRE')}

Problem:

Have a simple Cosmos DB table using Table API, and am using the Python SDK. Successfully inserted entity using the class azure.cosmosdb.table.tableservice.TableService and the method insert_or_replace_entity.

But when I try to update it (using merge_entity or update_entity) it gives me this error (cleaned up the formatting, paraphrasing):

AzureMissingResourceHttpError: Not Found
{
    "odata.error": {
        "code": "ResourceNotFound",
        "message": {
            "lang": "en-us",
            "value": "The specified resource does not exist. RequestID: [REDACTED]"
        }
    }
}

When I tried to instead use insert_or_merge_entity I get this error instead:

AzureHttpError: Bad Request
{
    "odata.error": {
        "code": "BadRequest",
        "message": {
            "lang": "en-us",
            "value": "Requests originating from scripts cannot reference partition keys other than the one for which client request was submitted."
        }
    }
}

I assume Cosmos DB finds the match based on the combo of PartitionKey and RowKey, but I am including valid PKs and RKs and still failing. Anyone have a solution?

Googled to no avail, double checked docs https://docs.microsoft.com/en-us/rest/api/storageservices/update-entity2.

4

1 回答 1

0

想出了答案。如果我将 PartitionKey 从 EntityProperty 更改为常规字符串,它就可以工作。一定是bug,我在GitHub上报告了https://github.com/Azure/azure-cosmos-table-python/issues/35

于 2019-01-24T18:21:42.230 回答