【Azure 存储服务】使用REST API操作Azure Storage Table,删除数据(Delete Entity)

问题描述

使用Azure Storage Table的REST API,实现根据过滤条件删除满足条件的数据,调用方法为 Delete Entity (Azure Storage)

问题实现

第一步:通过Azure Stroage 门户或者是其他工具(如:Azure Storage Explorer)生成Table的SAS Token

image.png

第二步:准备过滤条件,用 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

image.png

第三步:准备 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'

image.png

参考资料

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

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

分类: 【Azure 存储服务】

标签: Storage Table Delete

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容