问题描述
使用Azure Storage Table的REST API,实现根据过滤条件删除满足条件的数据,调用方法为 Delete Entity (Azure Storage)
问题实现
第一步:通过Azure Stroage 门户或者是其他工具(如:Azure Storage Explorer)生成Table的SAS Token
第二步:准备过滤条件,用 GET Entity进行验证,看是否可以查询出多条消息
示例 Filter 如:查看PartitionKey为3的全部Entity
Request URL:
https://myacountxxxxxxxxxxx.table.core.chinacloudapi.cn/table1?$filter=PartitionKey%20eq%20'3'%20&sv=2019-02-02&se=2023-02-28T11%3A35%3A14Z&sp=rd&sig=***********************&tn=table1
Header:
Accept: application/json
过滤条件为:$filter=PartitionKey%20eq%20'3'%20
第三步:准备 DELETE 请求
Request URL:
DELETE https://myacountxxxxxxxxxxx.table.core.chinacloudapi.cn/table1(PartitionKey='3',RowKey='333')?sv=2019-02-02&se=2023-02-28T11%3A35%3A14Z&sp=rd&sig=***********************&tn=table1
Header:
If-Match: *
Accept: application/json
删除条件中必须包含PartitionKey和RowKey,如果缺少任意一个值,都会报错:400 InvalidInput:The number of keys specified in the URI does not match number of key properties for the resource '**********.table1'
参考资料
Delete Entity (Azure Storage): https://learn.microsoft.com/en-us/rest/api/storageservices/delete-entity1
Query Entities : https://learn.microsoft.com/en-us/rest/api/storageservices/query-entities
标签:02,table1,20,Storage,Entity,Azure,Table From: https://www.cnblogs.com/lulight/p/17161770.html