【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
当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?