Track costs associated with a lab in Azure DevTest Labs
This article provides information on how to track the cost of your lab through Microsoft Cost Management by applying tags to the lab to filter costs.
DevTest Labs can create extra resource groups for resources related to your lab. The number of resource groups created depends on the features used by the lab and their settings. Because of the extra resource groups, it's often not straightforward to get a view of the total costs for your lab just by looking at Resource groups in the Azure portal. To create a single view of costs per lab in the Azure portal, you can use resource group Tags.
Apply Cost Management for DevTest Labs
The process for using cost management for DevTest Labs involves four steps:
- Create tags and enable tag inheritance in the Azure portal.
- Apply the tags to your DevTest Labs resources.
- Provide permissions to allow users to view their resource costs.
- Use Microsoft Cost Management to view and filter costs for your DevTest Labs resources, based on your tags.
You might create tags to allow users to track billed charges by cost center, business unit, team project, and so on.
The details for these steps are described in the following sections.
Create tags and enable tag inheritance
When DevTest Labs creates environments, it places each environment in its own resource group. For billing purposes, you must enable tag inheritance to ensure the lab tag definitions flow down from the resource group to the resources.
You can enable tag inheritance through billing properties or through Azure Policies. The billing properties method is the easiest and fastest to configure. However, it might affect billing reporting for other resources in the same subscription.
The following articles describe how to create tags and enable tag inheritance:
- Group and allocate costs by using tag inheritance
- Use the "Inherit a tag from the resource group" Azure Policy
If the lab is updated correctly by using the billing properties method, you see Tag inheritance is Enabled:
Apply tags to DevTest Labs
DevTest Labs automatically propagates tags applied at the lab level to resources created by the lab. For virtual machines, tags are applied to the billable resources. For environments, tags are applied to the resource group for the environment. To apply tags to your labs, follow the steps in Add tags to a lab.
Note
After you apply a new tag to your lab, the tag is automatically applied to new lab resources when they're created. If you want to apply a new or updated tag to existing resources, you can use a script to propagate the tag correctly. Use the Update-DevTestLabsTags script located in the DevTest Labs GitHub repository.
Provide permissions to view costs
DevTest Labs users don't automatically have permission to view costs for their resources by using Cost Management. To add the permissions, follow the instructions in enable users to view billing information. Assign the Billing Reader permission to users at the subscription level, if they don't already have permissions that include Billing Reader access.
For more information, see Manage access to Azure billing - Microsoft Cost Management.
View and filter costs
After DevTest Labs is configured to provide the lab-specific information for Microsoft Cost Management, you're ready to get started with Cost Management reporting - Azure - Microsoft Cost Management. You can visualize the costs in the Azure portal, download cost reporting information, or use Power BI to visualize the costs.
For a quick view of costs per lab, following these steps:
In the Azure portal, go to your lab, and select a resource group that has tags.
On the left menu, expand Cost Management, and select Cost analysis.
In the Cost analysis page, expand the View dropdown list, and select Daily Costs:
On the Cost Analysis page, expand the Group By filter, select Tag, and then select one of your applied tags:
The updated view shows costs in the subscription grouped by the tag according to the lab its resources. For more information, see the documentation on group and filter options in Cost Management.