title | titleSuffix | description | author | ms.author | ms.date | ms.topic | ms.service | ms.subservice | ms.custom | ms.reviewer |
---|---|---|---|---|---|---|---|---|---|---|
Get usage data with the Azure CLI |
Microsoft Cost Management |
This article explains how you get usage data with the Azure CLI. |
bandersmsft |
banders |
11/17/2023 |
conceptual |
cost-management-billing |
cost-management |
devx-track-azurecli |
jojoh |
This article explains how you get cost and usage data with the Azure CLI. If you want to get usage data using the Azure portal, see View and download your Azure usage and charges.
Start by preparing your environment for the Azure CLI.
[!INCLUDE azure-cli-prepare-your-environment-no-header.md]
After you sign in, use the export commands to export usage data to an Azure storage account. You can download the data from there.
-
Create a resource group or use an existing resource group. To create a resource group, run the group create command:
az group create --name TreyNetwork --location "East US"
-
Create a storage account to receive the exports or use an existing storage account. To create an account, use the storage account create command:
az storage account create --resource-group TreyNetwork --name cmdemo
-
Run the export create command to create the export:
az costmanagement export create --name DemoExport --type Usage \--scope "subscriptions/00000000-0000-0000-0000-000000000000" --storage-account-id cmdemo \--storage-container democontainer --timeframe MonthToDate --storage-directory demodirectory
- Read the Ingest usage details data article.
- Learn how to Get small cost datasets on demand.
- Understand usage details fields.
- Create and manage exported data in the Azure portal with exports.
- Automate Export creation and ingestion at scale using the API.