You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/billing/billing-review-service-usage-api.md
+97-75Lines changed: 97 additions & 75 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,22 +20,24 @@ ms.author: alleonar
20
20
21
21
# Review Azure resource usage using the REST API
22
22
23
+
Azure Cost Management APIs help you review and manage consumption of your Azure resources.
23
24
24
-
Azure [Consumption APIs](https://docs.microsoft.com/rest/api/consumption/) help you review the cost and usage data for your Azure resources.
25
+
In this article, you learn how to create a daily report that will generate a comma-separated value document with your hourly usage information, and then how to use filters to customize the report so that you can query the usage of virtual machines, databases, and tagged resources in an Azure resource group.
25
26
26
-
In this article, you learn how to retrieve and aggregate resource usage information for resources in an Azure resource group, as well as how to filter these results based on [Azure resource manager tags](https://docs.microsoft.com/azure/azure-resource-manager/resource-group-using-tags).
27
+
>[!NOTE]
28
+
> The Cost Management API is currently in private preview.
27
29
28
-
## Get usage for a resource group
30
+
## Create a basic cost management report
29
31
30
-
To get resource usage for compute, database, and other resources in a resource group, use the `usageDetails` REST operation and filter the results by resource group.
32
+
Use the `reports` operation in the Cost Management API to define how the cost reporting is generated and where the reports will be published to.
The `{subscription-id}` parameter is required and should contain a subscription ID that can access the {resource-group} resource group with a Reader role.
40
+
The `{subscriptionGuid}` parameter is required and should contain a subscription ID that can be read using the credentials provieed in the API token. The `{reportName}`
39
41
40
42
The following headers are required:
41
43
@@ -44,91 +46,111 @@ The following headers are required:
44
46
|*Content-Type:*| Required. Set to `application/json`. |
45
47
|*Authorization:*| Required. Set to a valid `Bearer` token. |
46
48
47
-
### Response
48
-
49
-
Status code 200 (OK) is returned for a successful response, which contains a list of usage statistics for each Azure resource in the resource group with subscriptipon ID `00000000-0000-0000-0000-000000000000`.
49
+
Configure the parameters of the report in the HTTP request body. In the example below, the report is set to generate every day when active, is a CSV file written to an Azure Storage blob container, and contains hourly cost information for all resources in resource group `westus`.
To get resource usage for resources in organized by tags, use the `usageDetails` REST operation and filter the results by the tag name using the `$filter` query parameter.
The `filter` and `dimensions` section of the request body when creating a report let you focus in on the costs for specific resource types. The previous request body shows how to filter by all resources in a region.
95
+
96
+
### Get all compute usage
97
+
98
+
Use the `ResourceType` dimension to report Azure virtual machine costs in your subscription across all regions.
99
+
100
+
```json
101
+
"filter": {
102
+
"dimensions": {
103
+
"name": "ResourceType",
104
+
"operator": "In",
105
+
"values": [
106
+
"Microsoft.ClassicCompute/virtualMachines",
107
+
"Microsoft.Compute/virtualMachines"
108
+
]
109
+
}
110
+
}
89
111
```
90
112
91
-
The `{subscription-id}` parameter is required and should contain a subscription ID that can access the tagged resources.
113
+
### Get all database usage
92
114
115
+
Use the `ResourceType` dimension to report Azure SQL Database costs in your subscription across all regions.
93
116
94
-
### Response
117
+
```json
118
+
"filter": {
119
+
"dimensions": {
120
+
"name": "ResourceType",
121
+
"operator": "In",
122
+
"values": [
123
+
"Microsoft.Sql/servers"
124
+
]
125
+
}
126
+
}
127
+
```
95
128
96
-
Status code 200 (OK) is returned for a successful response, which contains a list of usage statistics for each Azure resource in the resource group with subscriptipon ID `00000000-0000-0000-0000-000000000000` and tag name key vault pair is `dev` and `tools`.
129
+
### Report on specific instances
97
130
98
-
Sample response:
131
+
The `Resource` dimension lets you report costs for specific resources.
0 commit comments