【Azure 存储服务】调用REST API获取Stroage Account Table中所有的Entity计数 -- Count

简介: 【Azure 存储服务】调用REST API获取Stroage Account Table中所有的Entity计数 -- Count

问题描述

在Storage Account的使用中,如果想获取Table中全部Entity的计数以及大小,如果是REST API方式,如何来获取呢?

 

问题解答

在Azure中,所有服务的Metrics部分,都可以通过Azure Monitor 的REST API来获取。当需要查看Stroage Account的Metrcis时候,可以参考使用 List Metrics 接口:

 

文档链接:https://docs.microsoft.com/en-us/rest/api/monitor/metrics/list?tabs=HTTP

当然,如果是在中国区使用,需要修改文中的Endpoint为: https://management.chinacloudapi.cn 

所以,获取Storage Account中全部Table中Entity的总数API 为:

## 单独获取 TableEntityCount 
https://management.chinacloudapi.cn/subscriptions/<subscriptions>/resourceGroups/<resourceGroups>/providers/Microsoft.Storage/storageAccounts/<storageAccounts>
/tableServices/default/providers/microsoft.Insights/metrics?timespan=2022-09-03T08:30:00.000Z/2022-09-04T08:45:00.000Z&interval=PT15M
&metricnames=TableEntityCount&aggregation=average&metricNamespace=microsoft.storage%2Fstorageaccounts%2Ftableservices&autoadjusttimegrain=true
&validatedimensions=false&api-version=2021-05-01
## 单独获取 TableCapacity
https://management.chinacloudapi.cn/subscriptions/<subscriptions>/resourceGroups/<resourceGroups>/providers/Microsoft.Storage/storageAccounts/<storageAccounts>
/tableServices/default/providers/microsoft.Insights/metrics?timespan=2022-09-03T08:30:00.000Z/2022-09-04T08:45:00.000Z&interval=PT15M
&metricnames=TableCapacity&aggregation=average&metricNamespace=microsoft.storage%2Fstorageaccounts%2Ftableservices&autoadjusttimegrain=true
&validatedimensions=false&api-version=2021-05-01
## 合并获取 TableCapacity 和 TableEntityCount 
https://management.chinacloudapi.cn/subscriptions/<subscriptions>/resourceGroups/<resourceGroups>/providers/Microsoft.Storage/storageAccounts/<storageAccounts>
/tableServices/default/providers/microsoft.Insights/metrics?timespan=2022-09-03T08:30:00.000Z/2022-09-04T08:45:00.000Z&interval=PT15M
&metricnames=TableCapacity,TableEntityCount&aggregation=average&metricNamespace=microsoft.storage%2Fstorageaccounts%2Ftableservices&autoadjusttimegrain=true
&validatedimensions=false&api-version=2021-05-01
## 注意修改timespan

在调用以上接口时,必须获取 Authorization Bearer Token,否则会得到如下错误信息:

{
    "error": {
        "code": "AuthenticationFailed",
        "message": "Authentication failed. The 'Authorization' header is missing."
    }
}

获取Authorzation的方法请见:https://docs.microsoft.com/en-us/rest/api/monitor/metrics/list?tabs=HTTP#security 具体的步骤,可以参考旧博文:https://www.cnblogs.com/lulight/p/14279338.html

在Postman中验证结果如下:

 

 

参考资料

Microsoft.Storage/storageAccounts/tableServices:https://docs.microsoft.com/en-us/azure-stack/user/azure-stack-metrics-supported?view=azs-2206

 

Metrics - List : https://docs.microsoft.com/en-us/rest/api/monitor/metrics/list?tabs=HTTP#uri-parameters

相关文章
|
20天前
|
API 开发工具 网络架构
【Azure Developer】如何通过Azure Portal快速获取到对应操作的API并转换为Python代码
【Azure Developer】如何通过Azure Portal快速获取到对应操作的API并转换为Python代码
|
14天前
|
XML 安全 API
REST 和 SOAP API 有什么区别?
【8月更文挑战第31天】
21 0
|
14天前
|
JSON API 数据安全/隐私保护
哇塞!Django REST framework 太逆天啦!构建 API 服务从未如此轻松,你还不来试试?
【8月更文挑战第31天】Django REST framework(DRF)是基于Django框架的高效Web API开发工具,提供序列化、视图集、路由等功能,简化API构建流程。使用DRF可轻松实现数据的序列化与反序列化,并支持权限管理和认证机制以保障API安全。安装DRF只需通过`pip install djangorestframework`命令。要创建基本项目,先安装Django并创建新应用,定义模型、序列化器及视图集,最后配置路由。测试API时,可通过Postman发送HTTP请求验证功能。无论项目大小,DRF均能提供强大支持。
23 0
|
19天前
|
中间件 API 网络架构
Django后端架构开发:从匿名用户API节流到REST自定义认证
Django后端架构开发:从匿名用户API节流到REST自定义认证
12 0
|
20天前
|
存储 Kubernetes API
【APIM】Azure API Management Self-Host Gateway是否可以把请求的日志发送到Application Insights呢?让它和使用Azure上托管的 Gateway一样呢?
【APIM】Azure API Management Self-Host Gateway是否可以把请求的日志发送到Application Insights呢?让它和使用Azure上托管的 Gateway一样呢?
|
20天前
|
API 网络架构 C++
【Azure Key Vault】使用REST API调用Azure Key Vault Secret的示例步骤
【Azure Key Vault】使用REST API调用Azure Key Vault Secret的示例步骤
|
存储 API 开发工具
详说Azure的服务运行时API
详说Azure的服务运行时API  【版权声明】原创,作者为chszs,转载需注明。 一、服务运行时API简介   微软的Windows Azure服务总线提供了一整套REST风格的API,其中包括服务运行时API(Service Runtime API)和服务管理API(Service Management API),分别用于运行时操作和管理操作。
823 0
|
存储 API 开发工具
详说Azure的服务运行时API
版权声明:本文为博主chszs的原创文章,未经博主允许不得转载。 https://blog.csdn.net/chszs/article/details/7851794 详说Azure的服务运行时API  【版权声明】原创,作者为chszs,转载需注明。
716 0
|
30天前
|
机器人 API Python
智能对话机器人(通义版)会话接口API使用Quick Start
本文主要演示了如何使用python脚本快速调用智能对话机器人API接口,在参数获取的部分给出了具体的获取位置截图,这部分容易出错,第一次使用务必仔细参考接入参数获取的位置。
|
15天前
|
存储 JSON API
淘系API接口(解析返回的json数据)商品详情数据解析助力开发者
——在成长的路上,我们都是同行者。这篇关于商品详情API接口的文章,希望能帮助到您。期待与您继续分享更多API接口的知识,请记得关注Anzexi58哦! 淘宝API接口(如淘宝开放平台提供的API)允许开发者获取淘宝商品的各种信息,包括商品详情。然而,需要注意的是,直接访问淘宝的商品数据API通常需要商家身份或开发者权限,并且需要遵循淘宝的API使用协议。
淘系API接口(解析返回的json数据)商品详情数据解析助力开发者