Chapter 5. 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. Configuring a Storage Account Contributor and Reader roles for access
  3. Scheduling daily cost exports
Note

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 cost management from https://cloud.redhat.com/settings/sources/.

5.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 in order 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.

Note

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

  1. In the cloud.redhat.com platform, open the Sources menu (https://cloud.redhat.com/settings/sources/) 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 cloud.redhat.com Sources wizard, enter the Resource group name and Storage account name and click Next.

5.2. Configuring Azure roles

Red Hat recommends configuring dedicated credentials to grant cost management read-only access to Azure cost data. Configure a 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 cloud.redhat.com 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" --query '{"tenant": tenant, "client_id": appId, "secret": password}'
  4. In the cloud.redhat.com Sources wizard, enter your Azure Tenant ID, Client ID, and Client Secret.
  5. In Azure Cloud Shell, run the following command to create a cost management Reader role with your subscription ID. Copy the full command from the cloud.redhat.com Sources wizard, which will automatically substitute your Azure subscription ID obtained earlier for <SubscriptionID>:

    $ az role assignment create --role "Cost Management Reader" --assignee http://CostManagement --subscription <SubscriptionID>
  6. Click Next.

5.3. 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.

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

    • For Export type, select Daily export of billing-period-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 cloud.redhat.com 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 (https://cloud.redhat.com/cost-management/).