Associate Azure Virtual Machines with Cost Centers | Step-by-Step Guide

Associate Virtual Machines to Cost Centers

Question

You have an Azure subscription that contains a resource group named RG1. RG1 contains 100 virtual machines.

Your company has three cost centers named Manufacturing, Sales, and Finance.

You need to associate each virtual machine to a specific cost center.

What should you do?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

C

https://docs.microsoft.com/en-us/azure/billing/billing-getting-started https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-using-tags

The correct answer is C. Assign tags to the virtual machines.

To associate each virtual machine to a specific cost center, you can use Azure Resource Manager (ARM) tags. Tags are name/value pairs that can be applied to resources like virtual machines, and they provide a way to logically organize and categorize resources. By using tags, you can quickly identify and filter resources by specific attributes, such as cost center or owner.

To assign tags to your virtual machines, follow these steps:

  1. Navigate to the Azure portal (https://portal.azure.com/) and select your subscription and resource group (RG1 in this case).
  2. Select the virtual machines you want to tag.
  3. In the toolbar at the top of the page, click on the "Tags" button.
  4. In the tags pane, enter the name and value of the tag you want to assign. For example, you could use "CostCenter" as the name and "Sales" as the value for a virtual machine associated with the Sales cost center.
  5. Repeat step 4 for each tag you want to assign.
  6. Click the "Save" button to apply the tags to the selected virtual machines.

Once you have assigned tags to your virtual machines, you can use them to filter and group resources in the Azure portal, in Azure Resource Manager templates, and in Azure PowerShell or Azure CLI scripts. For example, you could filter virtual machines by cost center using the following Azure CLI command:

css
az vm list --query "[?tags.CostCenter=='Sales']"

This command would return a list of all virtual machines in the subscription that have a tag named "CostCenter" with a value of "Sales".