Microsoft Azure - Cost and Usage Extractor

Use the Microsoft Azure - Cost and Usage Extractor to collect the cost and usage data of the virtual machines that are provisioned in the Azure cloud. TrueSight Cloud Cost Control uses this resource usage and cost data to provide forecasting, simulated migration, and cost estimations. 

The ETL makes calls to the billing REST APIs to retrieve the cost and usage data. For information about these API calls, see API calls for the Azure Cost and Usage ETL.

This ETL works in conjunction with the Microsoft Azure - Azure API Extractor (Resource Manager model). The cost and usage data that is collected is associated with the corresponding business services and entities that the Azure API ETL collects.

To learn more about the collection of business service data by ETLs, see Collecting business service data.

You can configure the ETL to collect data from the following types of Azure subscriptions:

  • Pay-As-You-Go
  • Enterprise Agreement (Supported in TrueSight Capacity Optimization version 11.3.01.001 or later)


Information

In the first couple of days of a month, there might be a data latency of up to two days for the cost and usage data to be available for collection.

Collecting data by using the Azure Cost and Usage ETL

To collect data by using the Azure Cost and Usage ETL, do the following tasks:

I. Complete the preconfiguration tasks.

II. Configure the ETL.

Step I. Complete the preconfiguration tasks

Ensure that you set the currency as US dollars. The ETL does not support other currencies.

 Steps to set currency

    1. Log on to the Azure portal as a cloud administrator.
    2. From the left pane, select Cloud Management + Billing.

    3. Click a billing account ID and click Properties.
    4. From the Currency list, select USD.

    5. Save the changes.

For the Pay-As-You-Go Azure subscription

To collect the billing details of your Azure resources, the ETL needs to make the REST API calls to Azure services. To authenticate with these APIs, you must specify the following details during the ETL configuration:

  • Azure subscription ID
  • Azure offer ID
  • Azure Active Directory (AAD) tenant ID
  • Application ID
  • Authentication key
  • Business service tag key

To fetch these details, complete the following preconfiguration tasks:

StepDetails

Get your Azure subscription ID.

The subscription ID is a GUID that uniquely identifies your subscription to use Azure services.

 Steps to obtain Azure subscription ID

  1. Log in to the Azure portal.
  2. In the left pane, select Subscriptions.

  3. Locate the required subscription from the list of subscriptions, and note down the Azure subscription GUID.

Obtain the ID of the Azure pricing offer that is associated with the subscription.
 Steps to obtain Azure pricing offer ID

  1. Log in to the Azure portal.
  2. In the search box, type subscription, press Enter, and select Subscriptions.
  3. Select the subscription for which you want to get the offer ID.
    The Offer ID is displayed on the Overview page.

If you want to retrieve the cost and usage data for multiple subscriptions by using a single ETL, create a Subscription list file that contains all the subscription details.

The Subscription list file contains the following items for every subscription, separated by a (;):

  • Subscription ID
  • Pricing offer ID

The file can be in .txt or .csv format. You need a separate subscription file per tenant.

Important: If you are using this ETL along with the Azure API ETL, you can use a common Subscription list file. The Azure API ETL ignores the pricing offer ID values that are specified in the file.

 Steps to create a Subscription list file

  1. Open a new .txt or .csv file.
  2. Add the subscription ID and click Enter.
  3. Repeat step 2 for every subscription. For example:
    <subscription ID1>
    <subscription ID2>
  4. Save the updates.

Ensure that you have the required permissions to create an application in Azure Active Directory (AAD).
 Steps to check Azure Active Directory permissions

    1. Log in to the Azure portal.
    2. In the left pane, select Azure Active Directory. The Overview page is displayed.
    3. In the left pane of Azure Active Directory, click User Settings.

    4. In the right pane, review the App registrations setting.
      1. Yes - Allows any user in the Azure AD tenant to register AD apps.
      2. No - Only admin users can register AD apps.
        Select Overview and review your user information to verify whether your account is an admin account. If your account is assigned to the User role, contact your administrator to select Yes or assign you an administrator role.


        For more information about checking the Azure Active Directory permissions, see Check Azure Active Directory permissions .

Create an AAD application to access the Azure resources.
 Steps to create an AAD application

    1. Log in to the Azure portal.
    2. In the left pane, select Azure Active Directory. The Overview page is displayed.

    3. In the left pane of Azure Active Directory, click App Registrations, and click New application registration.

    4. Specify the following details and click Create.
      1. Name and sign-on URL for the application
      2. Application type as Web app/ API

      The AAD application is created and added to Azure Active Directory.

For more information about creating the Azure Active Directory application, see Create an Azure Active Directory application .

Obtain the Application ID and generate an authentication key for the application.
 Steps to obtain the application ID and authentication key

    1. Log in to the Azure portal.
    2. In the left pane, select Azure Active Directory. The Overview page is displayed.

    3. In the left pane of Azure Active Directory, click App Registrations, and in the right pane, select the application that you created in AAD.


    4. Note down the application ID.
    5. To generate an authentication key, click Settings > Keys.
    6. Provide a description and expiry duration for the key and click Save.
      Note down the generated authentication key value.

For more information about obtaining the application ID and generating the authentication key, see Get application ID and authentication key .

Obtain the Tenant ID, which is the ID of the AAD directory where you created the application.

 About Tenants

A Tenant is a representative of an organization within the Azure Active Directory. It is a dedicated instance of the Azure AD service. An AAD tenant is required for defining an application and assigning permissions to use REST APIs of other Azure services.

 Steps to obtain the tenant ID


    1. Log in to the Azure portal and select Azure Active Directory.
    2. In Azure Active Directory, click Properties.
    3. Note down the value of the Directory ID, which is your tenant ID.


      For more information about obtaining the tenant ID, see Get tenant ID .

Grant API access to your application.
 Steps to assign API access to your application

    1. Log on to the Azure portal.
    2. In the left pane, select Azure Active Directory. The Overview page is displayed.

    3. In the left pane of Azure Active Directory, click App Registrations, and in the right pane, select the application that you created in AAD.

    4. Click Required Permissions Add.
    5. On the Add API access page, complete the following steps:
      1. In the Select an API field, click Windows Azure Service Management API and click Select.
      2. In the Select permissions field, click Access Azure Service Management as organization users, and then click Select.

        Note: If you select the DELEGATE PERMISSIONS check box before selecting the permission, the Select button is not enabled.
    6. Click Done.


Grant the Reader role to the application.

Ensure that the account in your Azure subscription has the Owner or User Access Administration role to manage access to Azure resources. If your account is assigned the Contributor role, you cannot grant roles.

 Steps to grant the Reader role to the application

    1. Log on to the Azure portal.
    2. In the left pane, select Subscriptions.

    3. Locate the required subscription and click Access Control (IAM).
    4. Click Add, and select the role as Reader and type your application in the search field.
    5. Click Save.

For more information about granting the Reader role to the application, see Assign application to role .

For the Enterprise Agreement Azure subscription

To collect the billing details of your Azure resources, the ETL needs to access the billing API. To authenticate with the billing API, you must specify the following details during the ETL configuration:

  • Enrollment number
  • API access key

To fetch these details, complete the following preconfiguration tasks:

StepDetails

Obtain your enrollment number.

 About enrollment

An enrollment is like a master account that is associated with your organization's EA. All your Azure subscriptions and bills are associated with this enrollment number. When enterprise administrators first sign up for Azure, they receive an enrollment number and an access key from Microsoft. Administrators can then sign in to the Azure EA portal and start performing the admin tasks.

 Steps to view your enrollment number
  1. Log in to the Azure EA portal as an enterprise administrator.
    https://ea.azure.com
  2. Click Manage. The enrollment number is listed in the Enrollment Detail section.
Obtain the API access key that is required for authentication.
 Steps to view your API access key
  1. Log in to the Azure EA portal as an enterprise administrator.
    https://ea.azure.com
  2. Click Reports > Download Usage > API Access Key.
  3. Do one of the following steps:
    • If the primary key is available, click expand key and copy it.
    • If the primary key is not available, click Generate key, and then copy it.
Grant rights to the account owners and department administrators for viewing cost data.
 Steps to grant rights
  1. Log in to the Azure EA portal as an enterprise administrator.
    https://ea.azure.com
  2. Click Reports.
  3. Under Enrollment, enable the following:
    • DA view changes
    • AO view changes

Step II. Configure the ETL

You must configure the ETL to connect to Azure for collecting the cost and usage data of Azure entities. ETL configuration includes specifying the basic and optional advanced properties. While configuring the basic properties is sufficient, you can optionally configure the advanced properties for additional customization.

A. Configuring the basic properties

Some of the basic properties display default values. You can modify these values if required.

To configure the basic properties:

  1. In the TrueSight Capacity Optimization console, navigate to Administration ETL & System Tasks, and select ETL tasks.
  2. On the ETL tasks page, click Add > Add ETL. The Add ETL page displays the configuration properties. You must configure properties in the following tabs: Run configuration, Entity catalog, and Microsoft Azure Connection.

  3. On the Run configuration tab, select Microsoft Azure - Cost and Usage Extractor from the ETL module list. The name of the ETL is displayed in the ETL Task name field. You can edit this field to customize the name.

  4. Click the Entity catalog tab, and select one of the following options:
    • Shared Entity Catalog

      Retain the default selection to share the entity catalog with the Azure API ETL.
      • From the Sharing with Entity Catalog list, select the entity catalog name that is shared between ETLs.
    • Private Entity Catalog: Select if this is the only ETL that extracts data from the Azure resources.
  5. Click the Microsoft Azure Connection tab.
    If you are using EA Azure subscriptions, configure the following properties to import the cost and usage details from these subscriptions:



    PropertyDescription
    Enterprise Agreement accountSelect Yes.
    Enrollment numberSpecify the enrollment number that you obtained from Microsoft.
    API access keySpecify the API access key that you obtained during the preconfiguration tasks.


    If you are using Pay-As-You-Go Azure subscriptions, configure the following properties to import the cost and usage data from these subscriptions.

    PropertyDescription
    Enterprise Agreement accountSelect No.
    Subscription access modeDepending on your Azure subscription mode, select Single or Multiple. You must use the values that you obtained during the preconfiguration procedure.
    • For a single subscription, specify the following details:
      • ID of the subscription for which you want to retrieve data.
      • Azure pricing offer ID. The Offer ID code format consists of the “MS-AZR-“ prefix plus the unique Offer ID number.
    • For multiple subscriptions, specify the path of the file (.txt or .csv) that contains the subscription ID of all the subscriptions for which you want to retrieve the cost and usage data. The file contains the subscription ID and pricing offer ID, separated by a semi-colon (;), for each subscription:
    Tenant IDSpecify the Directory ID from your Active Directory properties.
    Application IDSpecify the Application ID from App registrations in the Azure Active Directory.
    Authentication keySpecify the authentication key that you generated after creating the web application in the Azure Active Directory.
    Business Service Tag KeySpecify the business service tag key that you used in the Azure API ETL for collecting business service data. The Microsoft Azure - Azure API extractor creates business service entities in the Workspace, and maps resources to each business service. The Microsoft Azure - Cost and Usage Extractor associates the cost of a resource under a specific business service by using the tags of collected resources.

    The default tag key is Service.

    Use proxy

    Specify whether you want to configure a proxy server, and provide the following details. The default selection is No.

    • The fully qualified domain name and the port number of the proxy server host.
    • The protocol for communicating with the proxy server. The default protocol is HTTPS.
    • If the proxy server requires authentication, select Yes, and specify the proxy server user name and password.

    Additionally, configure the following properties:

    PropertyDescription
    Business Service Tag KeySpecify the business service tag key that you used in the Azure API ETL for collecting business service data. The Microsoft Azure - Azure API extractor creates business service entities in the Workspace, and maps resources to each business service. The Microsoft Azure - Cost and Usage Extractor associates the cost of a resource under a specific business service by using the tags of collected resources.

    The default tag key is Service.

    Use proxy

    Specify whether you want to configure a proxy server, and provide the following details. The default selection is No.

    • The fully qualified domain name and the port number of the proxy server host.
    • The protocol for communicating with the proxy server. The default protocol is HTTPS.
    • If the proxy server requires authentication, select Yes, and specify the proxy server user name and password.
  6. (Optional) Override the default values of properties in the following tabs:

     Run configuration

    PropertyDescription
    Module selection

    Select one of the following options:

    • Based on datasource: This is the default selection.
    • Based on Open ETL template: Select only if you want to collect data that is not supported by TrueSight Capacity Optimization.
    Module descriptionA short description of the ETL module.
    Execute in simulation modeBy default, the ETL execution in simulation mode is selected to validate connectivity with the data source, and to ensure that the ETL does not have any configuration issues. In the simulation mode, the ETL does not load data into the database. This option is useful when you want to test a new ETL task. To run the ETL in the production mode, select No.
    BMC recommends that you run the ETL in the simulation mode after ETL configuration and then run it in the production mode.

     ETL task properties

    PropertyDescription
    Task groupSelect a task group to classify the ETL.
    Running on schedulerSelect one of the following schedulers for running the ETL:
    • Primary Scheduler: Runs on the Application Server.
    • Generic Scheduler: Runs on a separate computer.
    • Remote: Runs on remote computers.
    Maximum execution time before warningIndicates the number of hours, minutes, or days for which the ETL must run before generating warnings or alerts, if any.
    Frequency

    Select one of the following frequencies to run the ETL:

    • Predefined: This is the default selection. Select an hourly, daily, or weekly frequency, and then select a time and a day to start the ETL run accordingly.
    • Custom: Specify a custom frequency, select an appropriate unit of time, and then specify a day and a time to start the ETL run.

  7. Click Save.
    The ETL tasks page shows the details of the newly configured Azure Cost and Usage ETL. 

(Optional) B. Configuring the advanced properties

You can configure the advanced properties to change the way the ETL works or to define a period for data collection.

To configure the advanced properties:

  1. On the Add ETL page, click Advanced.
  2. Configure the following properties:

     Run configuration

    PropertyDescription
    Run configuration nameSpecify the name that you want to assign to this ETL task configuration. The default configuration name is displayed. You can use this name to differentiate between the run configuration settings of ETL tasks.
    Deploy statusSelect the deploy status for the ETL task. For example, you can initially select Test and change it to Production after verifying that the ETL run results are as expected.
    Log levelSpecify the level of details that you want to include in the ETL log file. Select one of the following options:
    • 1 - Light: Select to add the bare minimum activity logs to the log file.
    • 5 - Medium: Select to add the medium-detailed activity logs to the log file.
    • 10 - Verbose: Select to add detailed activity logs to the log file.

    Use log level 5 as a general practice. You can select log level 10 for debugging and troubleshooting purposes.

    Datasets

    Specify the datasets that you want to add to the ETL run configuration. The ETL collects data of metrics that are associated with these datasets.

    1. Click Edit.
    2. Select one (click) or more (shift+click) datasets from the Available datasets list and click >> to move them to the Selected datasets list.
    3. Click Apply.

    The ETL collects data of metrics associated with the datasets that are available in the Selected datasets list.

     Microsoft Azure Connection

    Property

    Description
    Extraction mode

    The extraction mode denotes the data collection period. Depending on the period you want to collect data for, select one of the following options:

    • Regular - daily import: Select to collect daily data. In the first run, the ETL collects data for the past six months. On the subsequent runs, it collects the daily data (after the last counter value).
    • Historical - import historical data (do not use for daily scheduling): Select to collect the historical data for the period that you specify in the Extraction months property.
      The default historical data collection period is 12 months.

    Recommendation

    BMC recommends that you create a separate Run configuration to extract historical data. Do not use the same Run configuration for your daily runs and historical data collection.

    By default, Regular is selected. After you run the ETL, the last counter value (LAST_EXTRACTION_MAX_TIME) is set to the day when the data was last extracted.

     Additional properties

    PropertyDescription
    List of properties

    Specify additional properties for the ETL that act as user inputs during run. You can specify these values now or you can do so later by accessing the "You can manually edit ETL properties from this page" link that is displayed for the ETL in the view mode.

    1. Click Add.
    2. In the etl.additional.prop.n field, specify an additional property.
    3. Click Apply.
      Repeat this task to add more properties.

     Loader configuration

    PropertyDescription
    Empty dataset behaviorSpecify the action for the loader if it encounters an empty dataset:
    • Warn: Generate a warning about loading an empty dataset.
    • Ignore: Ignore the empty dataset and continue parsing.
    ETL log file nameThe name of the file that contains the ETL run log. The default value is: %BASE/log/%AYEAR%AMONTH%ADAY%AHOUR%MINUTE%TASKID
    Maximum number of rows for CSV outputA numeric value to limit the size of the output files.
    CSV loader output file nameThe name of the file that is generated by the CSV loader. The default value is: %BASE/output/%DSNAME%AYEAR%AMONTH%ADAY%AHOUR%ZPROG%DSID%TASKID
    Capacity Optimization loader output file nameThe name of the file that is generated by the TrueSight Capacity Optimization loader. The default value is: %BASE/output/%DSNAME%AYEAR%AMONTH%ADAY%AHOUR%ZPROG%DSID%TASKID
    Detail mode
    Specify whether you want to collect raw data in addition to the standard data. Select one of the following options:
    • Standard: Data will be stored in the database in different tables at the following time granularities: Detail (configurable, by default: 5 minutes), Hourly, Daily, and Monthly.
    • Raw also: Data will be stored in the database in different tables at the following time granularities: Raw (as available from the original data source), Detail (configurable, by default: 5 minutes), Hourly, Daily, and Monthly.
    • Raw only: Data will be stored in the database in a table only at Raw granularity (as available from the original data source).
    For more information, see Accessing data using public views and Sizing and scalability considerations.
    Remove domain suffix from datasource name (Only for systems) Select True to remove the domain from the data source name. For example, server.domain.com will be saved as server. The default selection is False.
    Leave domain suffix to system name (Only for systems) Select True to keep the domain in the system name. For example: server.domain.com will be saved as is. The default selection is False.
    Update grouping object definition (Only for systems) Select True if you want the ETL to update the grouping object definition for a metric that is loaded by the ETL. The default selection is False.
    Skip entity creation (Only for ETL tasks sharing lookup with other tasks) Select True if you do not want this ETL to create an entity and discard data from its data source for entities not found in Capacity Optimization. It uses one of the other ETLs that share a lookup to create a new entity. The default selection is False.

     Scheduling options

    PropertyDescription
    Hour maskSpecify a value to run the task only during particular hours within a day. For example, 0 – 23 or 1, 3, 5 – 12.
    Day of week maskSelect the days so that the task can be run only on the selected days of the week. To avoid setting this filter, do not select any option for this field.
    Day of month maskSpecify a value to run the task only on the selected days of a month. For example, 5, 9, 18, 27 – 31.
    Apply mask validationSelect False to temporarily turn off the mask validation without removing any values. The default selection is True.
    Execute after timeSpecify a value in the hours:minutes format (for example, 05:00 or 16:00) to wait before the task is run. The task run begins only after the specified time is elapsed.
    EnqueueableSpecify whether you want to ignore the next run command or run it after the current task. Select one of the following options:
    • False: Ignores the next run command when a particular task is already running. This is the default selection.
    • True: Starts the next run command immediately after the current running task is completed.

  3. Click Save.
    The ETL tasks page shows the details of the newly configured Azure Cost and Usage ETL.

Step III. Run the ETL

After you configure the ETL, you can run it to collect data. You can run the ETL in the following modes:

A. Simulation mode: Only validates connection to the data source, does not collect data. Use this mode when you want to run the ETL for the first time or after you make any changes to the ETL configuration.

B. Production mode: Collects data from the data source.

Information

Ensure that you first run the Azure API ETL before running the Azure Cost and Usage ETL.

A. Running the ETL in the simulation mode

To run the ETL in the simulation mode:

  1. In the TrueSight Capacity Optimization console, navigate to Administration ETL & System Tasks, and select ETL tasks.
  2. On the ETL tasks page, click the ETL. The ETL details are displayed.



  3. In the Run configurations table, click Edit  to modify the ETL configuration settings.
  4. On the Run configuration tab, ensure that the Execute in simulation mode option is set to Yes, and click Save.
  5. Click Run active configuration. A confirmation message about the ETL run job submission is displayed.
  6. On the ETL tasks page, check the ETL run status in the Last exit column.
    OK Indicates that the ETL ran without any error. You are ready to run the ETL in the production mode.
  7.  If the ETL run status is Warning, Error, or Failed:
    1. On the ETL tasks page, click  in the last column of the ETL name row.
    2. Check the log and reconfigure the ETL if required.
    3. Run the ETL again.
    4. Repeat these steps until the ETL run status changes to OK.

B. Running the ETL in the production mode

You can run the ETL manually when required or schedule it to run at a specified time.

Running the ETL manually

  1. On the ETL tasks page, click the ETL. The ETL details are displayed.
  2. In the Run configurations table, click Edit  to modify the ETL configuration settings. The Edit run configuration page is displayed.
  3. On the Run configuration tab, select No for the Execute in simulation mode option, and click Save.
  4. To run the ETL immediately, click Run active configuration. A confirmation message about the ETL run job submission is displayed.
    When the ETL is run, it collects data from the source and transfers it to the TrueSight Capacity Optimization database.

Scheduling the ETL run

By default, the ETL is scheduled to run daily. You can customize this schedule by changing the frequency and period of running the ETL.

To configure the ETL run schedule:

  1. On the ETL tasks page, click the ETL, and click Edit. The ETL details are displayed.

  2. On the Edit task page, do the following, and click Save:

    • Specify a unique name and description for the ETL task.
    • In the Maximum execution time before warning field, specify the duration for which the ETL must run before generating warnings or alerts, if any.
    • Select a predefined or custom frequency for starting the ETL run. The default selection is Predefined.
    • Select the task group and the scheduler to which you want to assign the ETL task.
  3. Click Schedule. A message confirming the scheduling job submission is displayed.
    When the ETL runs as scheduled, it collects data from the source and transfers it to the TrueSight Capacity Optimization database.

Step IV. Verify data collection

Verify that the ETL ran successfully and the Azure cost data is refreshed in the TrueSight console.

To verify whether the ETL ran successfully:

  1. In the TrueSight Capacity Optimization console, click Administration > ETL and System Tasks > ETL tasks.
  2. In the Last exec time column corresponding to the ETL name, verify that the current date and time are displayed.

To verify whether the Azure cost data is refreshed:

  1. Log in to the TrueSight console.
  2. Click Cloud Cost Control, and verify whether the Azure cost data is refreshed.

API calls for the Pay-As-You-Go Azure subscriptions

The ETL makes the following calls to the Azure Billing REST API to retrieve data from your Pay-As-You-Go Azure subscriptions. 

TaskResource Management API call
AuthenticationPOST https://login.windows.net/<tenant_id>/oauth2/token (Application ID, Authentication key)
List all subscription detailsGET

https://management.azure.com/subscriptions?api-version=2015-01-01

Get resource rate card

GET https://management.azure.com/subscriptions/<Subscription_ID>/providers/Microsoft.Commerce/RateCard?api-version=2015-06-01-preview&$filter=OfferDurableId eq 'Offer Code' and Currency eq 'USD' and Locale eq 'en-US' and RegionInfo eq 'US'

 
Get resource usage

GET https://management.azure.com/subscriptions/<Subscription ID>/providers/Microsoft.Commerce/UsageAggregates?api-version=2015-06-01-preview&reportedStartTime=<Reported start date>&reportedEndTime=<Reported end date>&aggregationGranularity=Daily

Get consumption data for enrollment numberGET https://consumption.azure.com/v2/enrollments/<enrollment-number>/usagedetailsbycustomdate?startTime=<start-date>&endTime=<end-date>

API calls for the Enterprise Agreement Azure subscriptions

The ETL makes the following call to the Azure consumption REST API to retrieve data from your EA subscriptions. 

For more information, see the  Microsoft Azure Billing API Documentation .

Related topics

Collecting data

Analyzing and forecasting multi-cloud costs

Defining and managing on-premises costs

Microsoft Azure API documentation

Was this page helpful? Yes No Submitting... Thank you

Comments