【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

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

 

posted @   路边两盏灯  阅读(78)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示