Forum Discussion
romanazurelabit
Oct 02, 2024Copper Contributor
How to export the monthly cost summary for all the azure subscriptions in tenant? (automated)
Hi, We have multiple azure subscriptions in directory. How to export the Cost summary by for all subscriptions at once with tags? I would like to automatically export / send the costs for the past ...
balasubramanim
Oct 03, 2024Iron Contributor
You can export the monthly cost summary for all Azure subscriptions in a tenant automatically using Azure Cost Management APIs or Azure CLI commands.
Here's a simple Azure CLI command to achieve this:
- az costmanagement exports create --name "MonthlyCostSummary" --frequency Monthly --start-date 2023-01-01 --query "subscriptionName, tagName, cost" --output csv
For more information, refer to the Microsoft documentation:
Azure Cost Management APIs:
https://learn.microsoft.com/en-us/rest/api/cost-management/
https://learn.microsoft.com/en-us/rest/api/consumption/
Azure CLI commands for cost management:
https://learn.microsoft.com/en-us/cli/azure/costmanagement?view=azure-cli-latest
https://learn.microsoft.com/en-us/azure/cost-management-billing/automate/get-usage-data-azure-cli
Hope this helps you.
Many Thanks
Balasubramani.M