# Azure Stack

## Introduction

When deploying the Azure Stack [Extraction template](https://github.com/exivity/templates/tree/master/Azure%20Stack) for Exivity, some configuration is required within your Azure Stack environment and a lookup file needs to be created. The following process must be completed in order to report on Azure Stack consumption:

1. Create an Exivity Enterprise Application in your Azure AD for authentication
2. Configure a rate card lookup file
3. Configure an Extractor
4. Configure a Transformer
5. Create your Report

### Creating an Enterprise Application

For Exivity to authenticate with Azure Stack, you will need to create an application in the Azure AD where you have registered your Azure Stack management node:

![Example Exivity Azure AD Application](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHEKskLK6aXinV75Knl%2F-LKvlqOVHrRrdo4srZ_T%2F-LKvpmGjFIuXRxXcXpYG%2Fimage.png?alt=media\&token=44d87198-7dc6-4606-a3a7-5543982c8ca0)

{% hint style="warning" %}
Make sure to write down the **Application ID** and its corresponding **Secret**, since you will need these when configuring the Extractor later.
{% endhint %}

When you create this application in your Azure AD make sure it has (at least) the **Reader Role** *in your **Default Provider Subscription***:

![Providing Reader Role access to the Exivity Application](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHEKskLK6aXinV75Knl%2F-LKvlqOVHrRrdo4srZ_T%2F-LKvqfUqkRDTJZjoDj4L%2Fimage.png?alt=media\&token=bac80e76-8908-4c0b-93c5-b1afdf13156f)

### Create a rate card

As Microsoft does not provide rate card information via the Azure Stack Consumption API you will only obtain usage metrics from Azure Stack for all of the Meter IDs that are mentioned [here ](https://docs.microsoft.com/en-us/azure/azure-stack/azure-stack-usage-related-faq)by Microsoft.

![](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHEKskLK6aXinV75Knl%2F-LKvlqOVHrRrdo4srZ_T%2F-LKvsxxdSFIhv6DxfuWT%2Fimage.png?alt=media\&token=4b4f6761-f007-44b0-8eef-d389d9ebb2f8)

Exivity provides a[ template rate card](https://github.com/exivity/templates/blob/master/Azure%20Stack/azure_stack_example_rates.csv.trs) that you can use for creating your own rates. Please bear in mind that these rates are fictional, thus you should update it with your preferred values. However to get started, you can use the file linked above by placing it as a **csv** file in your Exivity home folder at the following location:

`%EXIVITY_HOME_PATH%\system\extracted\AzureStack\rates\azure_stack_example_rates.csv`

{% hint style="info" %}
Once loaded into the system using a Transformer you will be able to change the rates easily through the GUI. This will also enable you to test any draft rates.
{% endhint %}

### Configure Extractor

To create the Extractor, browse to **Data Sources > Extractors** in the Exivity GUI and click the **Create Extractor** button. This will try to connect to the Exivity Github account to obtain a list of available templates. For Azure Stack:

* Pick [Azure\_Stack\_Extractor\_(App+Secret)](https://github.com/exivity/templates/blob/master/Azure%20Stack/Azure_Stack_Extractor_\(App%2BSecret\).use) from the list
* Provide a name for the Extractor in the **name** field
* Click the **Create** button.

Once you've created the Extractor, go to first tab: *Variables*

![Azure Stack Variables](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHEKskLK6aXinV75Knl%2F-LKvlqOVHrRrdo4srZ_T%2F-LKvvJetlH-gKvbt_haZ%2Fimage.png?alt=media\&token=5af423fd-a23b-4a97-9f9b-9c933984d93a)

Fill in all required variables marked within the red box in above screenshot. If you don't know some of the required GUIDs, most of these can be obtained by browsing to the Azure Stack management node URL:

* <https://adminmanagement.\\*\\*\\>\<your.domain.com>\*\*/metadata/endpoints?api-version=2015-01-01

Another way to obtain some of this information is using the *Diagnostics* button in your management portal:

![Diagnostics file from Azure Stack management portal](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHEKskLK6aXinV75Knl%2F-LKwMPIREZFzOikguxA_%2F-LKwMDWzRmyst3VUXB8z%2Fimage.png?alt=media\&token=81ea370c-84d4-4516-9689-621555499410)

When you click the *Show Diagnostics* link, it should download a JSON file containing most of the parameters you'll need, such as Provider GUID, Audience GUID etc.

Once you've filled in all details, go to the **Run** tab to execute the Extractor for a single day:

![Executing the Extractor manually for a single day](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHEKskLK6aXinV75Knl%2F-LKvvTQII_LM3fkQhXOt%2F-LKvwzr9Mp0tT8HakDaB%2Fimage.png?alt=media\&token=3a757427-1e9c-48de-baa6-5b2bcf01cec6)

The Extractor requires two parameters in yyyyMMdd format:

* **from\_date** is the date for which you wish to collect consumption data
* **to\_date** should be the date immediately following **from\_date**

These should be specified as shown in the screenshot above, separated with a space.

When you click the *Run Now* button, you should get a successful result.

### Configure Transformer

Once you have successfully run your Azure Stack Extractor, you can create a Transformer template via **Data Sources > Transformers** in the Exivity GUI. Browse to this location and click the **Create Transformer** button. Make any changes that you feel necessary and then select the **run** tab to execute it for a single day as a test.

{% hint style="warning" %}
Make sure that when running the Transformer you select **custom range** in the drop-down menu labelled **Run for** and select the same day as for which you have extracted consumption data in the previous step.
{% endhint %}

### Create a Report

Once you have run both your Extractor and Transformer successfully create a *Report Definition* via the menu option **Reports > Definitions***:*

![Creating a Report Definition](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHEKskLK6aXinV75Knl%2F-LKvvTQII_LM3fkQhXOt%2F-LKvyackYSXxMCLS_qGR%2Fimage.png?alt=media\&token=f65cc274-2b2f-4876-8ab0-2f8b49ce887e)

Select the column(s) by which you would like to break down the costs. Once you have created the report, you should then click the *Prepare Report* button after first making sure you have selected a valid date range from the date selector shown when preparing the report.

![Prepare your Report](https://1141395848-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LHEKskLK6aXinV75Knl%2F-LKvvTQII_LM3fkQhXOt%2F-LKvzU8fWwJLa9Gs1DUw%2Fimage.png?alt=media\&token=4eaa51c9-e558-42df-ae92-55807eab3807)

Once this is done you should be able to run any of **Accounts**, **Instances**, **Services** or **Invoices** report types located under the **Report** menu for the date range you prepared the report for.
