Tagging and Naming Your Resources in Azure

CloudClarity
4 min readJul 8, 2021

Get started with governance and stay on top of your cloud usage and costs with the simplest building blocks in Azure: tags.

Table of Contents

1. Defining Tagging

2. How to Tag in Azure

3. Using Tags

4. Cost and Tagging

5. Naming Resources

1. Defining Tagging

To put simply, tagging is when owners or administrators assign metadata to resources in Azure. One of the biggest benefits to tagging is its assistance with cost management as well as its ability to document what something is, where it is and why. Work automation also benefits greatly from using tags by grouping resources from multiple groups together using metadata.

CloudClarity makes tagging even easier, and allows you to validate tagging health across all scopes in order to ensure your cloud environment’s as efficient as possible.

2. How to Tag in Azure

First of all, to begin tagging, the Contributor role (as well as any role above it) has to be assigned to you. This will be a quick and easy walkthrough to get you started on tagging with our help.

1. Go to your Azure portal

2. Select “All services” from the navigation on the very left, and search for ‘tags’ in order to be led to your Tag view. Any tags currently being used will be listed here as shortcuts to the resources.

3. Navigate to a resource that needs to be tagged and, in the overview section, select “Click here to add tags”.

4. Specify a tag name and value using a key-value pair.

5. Save this, keeping in mind that the tags get added to the resource group and not the individual resource within this group.

6. Returning to the overview in step 1 will now show the newly added tags.

3. Using Tags

Scripting or custom code can now be applied in order to control resources within tags. It’s recommended to use Microsoft Windows Terminal for this due to its leniency of adding other shells such as Azure Cloud Shell, which we will be using.

Azure CLI will also be needed. It is a command-line interface for accessing and handling Azure subscriptions and resources. You have to install it locally, but you can also run it through Azure Cloud Shell.

1. Install Windows Terminal and, with assistance from Microsoft, enable Azure Cloud Shell. It can now be seen from the menu at the top.

2. Choose the tenant you’d like to authenticate against the Azure Cloud Shell.

3. Log in and use the command az account list-locations in order to view all Azure locations and geos.

4. Execute the command az group list — tag CostCenter=IT, this will search through all resource groups and find the ones with a tag that matches IT cost centre.

5. Execute the following command via Azure CLI az resource tag –tags Customer=[NAME OF CUSTOMER] –resource-group backuprg –name [NAME OF TENANT]–resource-type Microsoft.Storage/ storageAccounts. This adds a customer tag, allowing us to verify which customer’s backups are stored within that storage account.
This command is quite long for a reason; it requires specific parameters on the resource group, resource and its nature. Using this command will add a new tag to the storage account directly, rather than the resource group where we put the prior two tags.

6. Return to the Azure Portal and open your storage account. We are verifying if the command executed successfully.

Tags are great. Their infusion can be automated by you from (almost) anywhere. IT managers and developers infuse tags during implementation to their Azure Resource Manager (ARM) templates or while an implementation process is being coordinated through Azure DevOps’ Azure Pipeline service.

4. Cost and Tagging

We mentioned earlier than tags can be linked with cost, which can help you manage and allocate your expenses. This can be influenced to correspond with certain resource costs on Azure to specific cost centres (such as IT). Then, tags can implement predefined processes when a specific budget has been reached.

5. Naming Resources

There is no single naming policy or set of rules that must be followed when you’re naming your IT resources, a lot of it is up to you. There are however some boundaries we recommend keeping in place in order to prevent your environment from devolving into chaos.

To begin, avoid using linguistic idiosyncrasies and local dialects. Having a subscription name with accented letters and symbols such as Ä, Ö, Å and € will pose a challenge for reporting, non-local administrators, and your scripts.

It’s also recommended to use clear abbreviations and shorthanded names understood universally (such as web, dev, win, linux, etc.) Avoid inventing new abbreviations as this could lead to a lot of confusion later down the line. Also, whatever naming pattern you do decide to employ, make sure it’s consistent and you don’t stray from it. Microsoft recommends the following:

<Company> <Department (optional)> <Product Line (optional)> <Environment>

And finally, to add on to our first point, avoid using special characters entirely, such as $, /, _, ~, etc.

We know this can all be a bit overwhelming and that’s why we’ve created CloudClarity, to make tagging and managing your Azure environment easier. Visit our site to find out more http://portal.cloudclarity.app/.

--

--

CloudClarity

Blog for CloudClarity, Manage, audit and tag your Azure bill like never before portal.cloudclarity.app