Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 2.46 KB

get-usage-data-azure-cli.md

File metadata and controls

52 lines (38 loc) · 2.46 KB
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

Get usage data with the Azure CLI

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.

Set up the Azure CLI

Start by preparing your environment for the Azure CLI.

[!INCLUDE azure-cli-prepare-your-environment-no-header.md]

Configure an export job to export cost data to Azure storage

After you sign in, use the export commands to export usage data to an Azure storage account. You can download the data from there.

  1. 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"
    
  2. 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
    
  3. 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
    

Related content