Setup Azure Costs
Create a Service Principal
In order to access resources a Service Principal needs to be created in your Tenant.
It is easiest to do this via the AZ CLI.
-
First, make sure you are logged in:
az login
Follow the instructions to login.
-
Once logged in, your subscriptions will be returned:
[ { "cloudName": "AzureCloud", "id": "2d7e700a-8793-45ff-ba0a-9d92d15edf56", // this is your Subscription ID "isDefault": "true", "name": "Pay-As-You-Go", "state": "Enabled", "tenantId": "e522969-635a-4327-8807-7f7aac328e82", "user": { "name": "[email protected]", "type": "user" } } ]
-
Next, set your active subscription:
az account set --subscription="${id}"
-
Then create a Service Principal for env0 to be able to query your Azure costs:
az ad sp create-for-rbac -n "${name-of-your-choice}"
That will return the metadata for your Service Principal:
{ "appId": "2dc2b1b3-11dd-4eb5-845-84fc-5bda87620cea", // this is your Client ID "displayName": "who", "name": "http://who", "password": "ab735025-151e-4337-b154-b7833d6929a9", // this is your Client Secret "tenant": "5c8c7547-dd3f-4750-a8d9-f2e04e6015ba" // this is your Tenant ID }
Add the Azure cost credentials to your Organization
- Under your Organization Settings, Select the Credentials tab
- Click Add Credential
- Select the
Azure Credentials
type. - Fill in the form with the credentials from the previous steps:
Client ID
=appId
(From step 4)
Client Secret
=password
(From step 4)
Tenant ID
=tenant
(From step 4)
Subscription ID
=id
(From step 1) - Click Add
Enable cost monitoring
- Go to the Project Settings of the desired project.
- Select the Credentials tab.
- Check the appropriate cloud provider checkbox, and select the credential you created in the steps above.
- Click Save.
Data Visibility
Please note that after the configuration of cost monitoring is complete, a redeploy to the environments is needed, and once redeployed it can take 24-48 hours for data to show, depending on the cloud providerâs cost exploration capabilities.
Updated 8 months ago