Track costs associated with a lab in Azure DevTest Labs

This article provides information on how to track the cost of your lab through Azure Cost Management by applying tags to the lab to filter costs. DevTest Labs may create more resource groups for resources related to the lab (depending on the features used and the settings of the lab). For this reason, it’s often not straightforward to get a view of the total costs for a lab just by looking at Resource Groups. To create a single view of costs per lab, tags are used.

Steps to Leverage Cost Management for DevTest Labs

These are the steps needed to use cost management for DevTest Labs. More details are captured in the following sections.

  1. Enable tag inheritance for costs.
  2. Apply tags to the DevTest Labs (cost center, business unit, etc.).
  3. Provide permissions to allow users to view costs.
  4. Use Azure Cost Management for viewing/filtering costs for DevTest Labs, based on the tags.

Step 1: Enable Tag Inheritance for Tags on Resource Groups

When DevTest Labs creates environments, they are each placed in their own resource group. For billing purposes, you must enable tag inheritance to ensure that the lab tags 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.

If updated correctly using the billing properties method, you see that Tag Inheritance now shows Enabled:

Screenshot that shows Tag Inheritance is enabled.

Step 2: Apply Tags to DevTest Labs

DevTest Labs automatically propagates tags applied at the lab level to the resources that are created by the lab. This includes virtual machines (tags are applied to the billable resources) and environments (tags are applied to the resource group for the environment). Follow the steps in this article to apply tags to your labs: Add tags to a lab.

Screenshot that shows tags in DevTest Labs in the Azure portal.

Note

It’s important to remember that tags are propagated for any resources created after the tag has been applied to the lab. If there are existing resources that must be updated with the new tags, there's a script available to propagate the new/updated tags correctly. If you have existing resources and want to apply the lab tags, use the Update-DevTestLabsTags script located in the DevTest Labs GitHub Repo.

Step 3: Provide permissions to allow users to view costs

DevTest Labs users don’t automatically have permission to view costs for their resources via Cost Management. There's one more step to 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. More information is found here on managing access to billing information: Manage access to Azure billing - Microsoft Cost Management.

Step 4: Use Azure Cost Management for viewing and filtering costs for DevTest Labs

Now that DevTest Labs is configured to provide the lab-specific information for Cost Management, start here on Cost Management Reporting to view costs: 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, see the following steps:

  1. Select Cost Management and then on Cost analysis
  2. Select Daily Costs

Screenshot that shows the daily costs card.

  1. On the Custom: Cost Analysis page, select the Group By filter, choose Tag and then the Tag Name (like "CostCenter") to group by. Refer to the documentation on group and filter options in Cost Management for more details.

The resulting view shows costs in the subscription grouped by the tag (which is grouping by the lab & its resources).

  • Define lab policies. Learn how to set the various policies used to govern how your lab and its virtual machines (VMs) are used.
  • Create custom image. When you create a virtual machine (VM), you specify a base. The base can be either a custom image or a Marketplace image. This article describes how to create a custom image from a virtual hard disk (VHD) file.
  • Configure Marketplace images. DevTest Labs supports creating VMs based on Azure Marketplace images. This article illustrates how to specify Azure Marketplace images you can use when creating VMs in a lab.
  • Create a VM in a lab. This article illustrates how to create a VM from a custom or Marketplace base image, and work with artifacts in the VM.