Adding a Microsoft Azure source to cost management

Cost Management Service 2023

Learn how to add and configure your Microsoft Azure sources

Red Hat Customer Content Services


This guide describes how to add a Microsoft Azure source to cost management. Cost management is part of the Red Hat Insights portfolio of services. The Red Hat Insights suite of advanced analytical tools helps you to identify and prioritize impacts on your operations, security, and business.

Chapter 1. Adding a Microsoft Azure source to cost management

Configure your Microsoft Azure account to allow cost management access.

Configuring your Azure account to be a cost management source requires:

  1. Creating a storage account and resource group
  2. Choosing the appropriate scope for your cost export
  3. Configuring a Storage Account Contributor and Reader roles for access
  4. Scheduling daily cost exports

As non-Red Hat products and documentation can change without notice, instructions for configuring the third-party sources provided in this guide are general and correct at the time of publishing. See the Microsoft Azure documentation for the most up-to-date and accurate information.

Add your Azure source to hybrid committed spend from the Sources page.

1.1. Creating an Azure resource group and storage account

Cost export data is written to a storage account, which exists within a resource group. The resource group must be accessible by cost management to read the Azure cost data.

Create a new storage account in Azure to contain the cost data and metrics that cost management will collect. This requires a resource group; Red Hat recommends creating a dedicated resource group for this storage account.


You must have a Red Hat account user with Sources Administrator entitlements before you can add sources to cost management.

  1. From Red Hat Hybrid Cloud Console, go to the Sources page to begin adding an Azure source to cost management:

    1. Navigate to Sources and click Add a source to open the Sources wizard.
    2. Enter a name for your source and click Next.
    3. Select cost management as the application and Microsoft Azure as the source type. Click Next.
  2. Create a resource group and storage account in your Azure account using the instructions in the See Azure documentation Create a storage account.

Make a note of the resource group and storage account. They will be needed in subsequent steps.

  1. In the Red Hat Hybrid Cloud Console Sources wizard, enter the Resource group name and Storage account name and click Next.

1.2. Choosing an Azure cost export scope

You can create cost export data with differing levels of granularity using scopes in Azure Cloud. Azure supports cost exports scoped as small as a resource group to as large as a billing account containing numerous subscriptions. Depending on the cost data requirements for a given use case, scopes can simplify the configuration of cost management by encompassing multiple subscriptions or isolating access to select resource groups.


For more information about how scopes work in Azure, see Understand and work with scopes in the Azure documentation.

Run one or more of the following commands in the Azure Cloud Shell to collect the desired scopes for your cost export:

  1. To collect your Resource Group scope, replace ResourceGroupName with the name of the Resource Group and run:

    $ az group show --name {ResourceGroupName} | jq .id | tr -d '"'
  2. To collect your Subscription scope, run:

    $ az account show --query "{ id: id }" | jq '.id' | tr -d '"' | awk '{print "/subscriptions/"$0}'
  3. To collect your Billing Account scope, replace billingAccountName with the name of the Billing Account and run:

    $ az billing account show --name "{billingAccountName}" | jq '.id' | tr -d '"'
  4. To collect your Enrollment Account scope, replace enrollmentAccountName with the name of the Enrollment Account and run:

    $ az billing enrollment-account show --name "{enrollmentAccountName}" | jq '.id' | tr -d '"'
  5. To collect your Management Group scope, replace GroupName with the name of the Management Group and run:

    $ az account management-group show --name "{GroupName}" | jq '.id' | tr -d '"'
  6. To collect your Billing Profile scope, replace billingAccountName and billingProfileName with the names of the Billing Account and Billing Profile and run:

    $ az billing profile show --account-name "{billingAccountName}" --name "{billingProfileName}" | jq '.id' | tr -d '"'
  7. To collect your Invoice Section scope, replace billingAccountName, billingProfileName, invoiceSectionName with the names of the Billing Account, Billing Profile, and Invoice Section and run:

    $ az billing invoice section show --account-name "{billingAccountName}" --profile-name "{billingProfileName}" --name "{invoiceSectionName}" | jq '.id' | tr -d '"'

1.3. Configuring Azure roles

Red Hat recommends configuring dedicated credentials to grant cost management read-only access to Azure cost data. Configure a service principal with Storage Account Contributor and Reader role in Azure to provide this access to cost management.

  1. In Azure Cloud Shell, run the following command to obtain your Subscription ID:

    $ az account show --query "{subscription_id: id }"
  2. In the Red Hat Hybrid Cloud Console Sources wizard, enter your Subscription ID. Click Next to move to the next screen.
  3. In Azure Cloud Shell, run the following command to create a cost management Storage Account Contributor role, and obtain your tenant ID, client (application) ID, and client secret:

    $ az ad sp create-for-rbac -n "CostManagement" --role "Storage Account Contributor"  --scope /subscriptions/{subscriptionId}/resourceGroups/{resourceGroup1} --query '{"tenant": tenant, "client_id": appId, "secret": password}'
  4. In the Red Hat Hybrid Cloud Console Sources wizard, enter your Azure Tenant ID, Client ID, and Client Secret.
  5. Create a Reader role in Azure for cost management.

    1. If the cost export scope is for an Enterprise Agreement (EA) account then launch the Azure Enterprise Portal to give the service principal created above Administrator role on the account. For more information, see Assign access to Cost Management data in the Azure documentation.
    2. If the cost export scope is for a billing account, billing profile, or invoice section in a Microsoft Customer Agreement (MCA), launch the Cost Management and Billing service in the Azure Portal. Select the appropriate scope and give the service principal created above the appropriate Reader role from the IAM view. For more information, see Understand Microsoft Customer Agreement administrative roles in Azure in the Azure documentation.
    3. If the cost export scope is for a resource group, subscription, or management group then in Azure Cloud Shell, run the following command to create a cost management Reader role:

      $ az role assignment create --assignee "<your_Client_ID>" --role "Cost Management Reader" --scope {costExportScope}
  6. Click Next.

1.4. Configuring a daily Azure data export schedule

Create a recurring task to export your cost data on a daily basis automatically to your Azure storage account, where cost management will retrieve the data at the desired scope.

  1. In Azure, add a new export as described in the instructions in the Azure article Create and manage exported data.

    • Select a Name for the export that should be supplied in the Red Hat Hybrid Cloud Console Sources wizard.
    • For Export type, select Daily export of month-to-date costs.
    • For Storage account, select the account you created earlier.
    • Enter any value for the container name and directory path for the export. These values provide the tree structure in the storage account where report files are stored.
    • Click Run now to start exporting data to the Azure storage container.
  2. In the Red Hat Hybrid Cloud Console Sources wizard, click Next when you have created the export schedule and review the source details.
  3. Click Finish to complete adding the Azure source to cost management.

After the schedule is created, cost management will begin polling Azure for cost data, which will appear on the cost management dashboard.

Chapter 2. Next steps for managing your costs

After adding your OpenShift Container Platform and Microsoft Azure sources, in addition to showing cost data by source, cost management will automatically show Azure cost and usage related to running your OpenShift Container Platform clusters on their platform.

On the cost management Overview page, your cost data will be sorted into OpenShift and Infrastructure tabs. From here, you can use Perspective to select different views of your cost data.

You can also use the left navigation menu to view the additional details of your costs by service.

2.1. Limit access to cost management resources

After adding and configuring sources in cost management, it is a good idea to limit access to cost data and resources. For example, you may not want users to have access to all cost data, but instead only data specific to their projects or organization. Using role-based access control, you can limit the visibility of resources involved in cost management reports. For example, you may want to restrict a user’s view to only AWS sources, rather than the entire environment.

For more information about limiting access see, Limiting access to cost management resources.

2.2. Configure tagging for your sources

The cost management application tracks cloud and infrastructure costs using tags (called labels in OpenShift), which you can refine to filter and attribute to resources. Tags in cost management allow you to organize your resources by cost and to allocate the costs to different parts of your cloud infrastructure.


Tags and labels can only be configured directly on a source. While you can choose what tags are activated in cost management, you cannot edit tags and labels in the cost management application.

See Managing cost data using tagging to learn more about:

  • Planning your tagging strategy to organize your view of cost data.
  • Understanding how cost management associates tags.
  • Configuring tags and labels on your sources.

2.3. Configure cost models to accurately report costs

Now that you have configured your sources to collect cost and usage data into cost management, you can configure cost models to associate prices to metrics and usage, and fine-tune the costs of running your cloud.

A cost model is a framework used to define the calculations for the costs stored in cost management, using raw costs and metrics. Costs generated by a cost model can be recorded, categorized and distributed to specific customers, business units or projects.

From the Cost Models area of cost management, you can:

  • Classify your costs as infrastructure or supplementary costs.
  • Capture monthly costs for OpenShift nodes and clusters.
  • Apply a markup to account for additional support costs.
  • Learn how to configure a cost model in Using cost models.

2.4. Use the Cost Explorer to visualize your costs

The cost management Cost Explorer allows you to create custom graphs of time-scaled cost and usage information to better visualize and interpret your costs.

See Visualizing your costs using Cost Explorer to learn more about:

  • Using Cost Explorer to identify abnormal events.
  • Understanding how your cost data changes over time.
  • Creating custom bar charts of your cost and usage data.
  • Exporting custom cost data tables.

Providing feedback on Red Hat documentation

We appreciate your feedback on our documentation. To provide feedback, highlight text in a document and add comments.


  • You are logged in to the Red Hat Customer Portal.
  • In the Red Hat Customer Portal, the document is in the Multi-page HTML viewing format.


To provide your feedback, perform the following steps:

  1. Click the Feedback button in the upper-right corner of the document to see existing feedback.


    The feedback feature is enabled only in the Multi-page HTML format.

  2. Highlight the section of the document where you want to provide feedback.
  3. Click the Add Feedback pop-up that appears near the highlighted text.

    A text box appears in the feedback section on the right side of the page.

  4. Enter your feedback in the text box and click Submit.

    A documentation issue is created.

  5. To view the issue, click the issue link in the feedback view.

Legal Notice

Copyright © 2023 Red Hat, Inc.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is available at In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert, Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift, Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States and other countries.
Linux® is the registered trademark of Linus Torvalds in the United States and other countries.
Java® is a registered trademark of Oracle and/or its affiliates.
XFS® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States and/or other countries.
MySQL® is a registered trademark of MySQL AB in the United States, the European Union and other countries.
Node.js® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the official Joyent Node.js open source or commercial project.
The OpenStack® Word Mark and OpenStack logo are either registered trademarks/service marks or trademarks/service marks of the OpenStack Foundation, in the United States and other countries and are used with the OpenStack Foundation's permission. We are not affiliated with, endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
All other trademarks are the property of their respective owners.