AZURE TAGGING

Implement a tagging strategy

Tags in Azure provide metadata related to assets, enabling better management, organization and tracking. We can thus define a tagging strategy according to the needs of our organization. We can therefore determine which tags (for example, environment, service, cost center) are essential to the categorization and management of resources. A tag is a key pair /value applied to an Azure resource and you can create up to 50 tags per resource in Azure.

Here is an example of tag configuration·     

Environment: development, quality, pre-production and production·    

Cost center: Tags created by cost center serve a variety of purposes, including billing needs (monitoring, tracking), allocating resources to the respective teams or departments responsible for costs, and using the Cost Center tag as a filter for billing reports. ·      

Department(or service): The “Department” tag categorizes resources based on the different departments or teams within an organization that use those resources.ü It allows you to assign resources to specific departments or teams within the organization. For example, IT, marketing, sales, finance, operations, etc.ü It allows accurate allocation of costs associated with cloud resources to the respective departments, thereby facilitating budgeting and financial planning. ·      

Application: The “Application” tag is used to associate resources with specific applications or projects within an organization.ü helps link resources to the applications or services they support, making it easier to identify which resources are part of which applications.ü facilitates management and maintenance efficient resources belonging to a particular application.ü enables the grouping of resources belonging to a single application, thereby facilitating management and monitoring.ü helps in tracking changes, updates or versions specific to the resources of an application.·  

Type of resources: This tag categorizes resources based on their nature or functionality.ü helps classify resources based on their type, such as databases, servers, storage, network components, etc.üfacilitates quick identification of set of resources by specific type.ü allows better allocation of resources based on their types to ensure efficient use.ü helps to solve problems specific to certain types of resources and optimize them according to their functionalities.·      

Resource category: Similar to The “Resource Type” tag, the “Resource Category” tag further categorizes resources based on broader classifications within each resource type. ü provides more detailed categorization within resource types. For example, within the “Database” type, categories might include SQL databases, NoSQL databases, etc. ü provides a more specific way to identify and manage resources based on their categories. ü Enables more targeted management practices based on specific categories of resources. ü Enables better optimization strategies by focusing on specific categories within resource types·     

Resource creation mode: This tag indicates how the resource was created or provisioned, thus providing insight into its origin or deployment method.ü helps to know if resources were created manually, via automation scripts, through a specific platform feature, etc.ühelps to audit creation methods resources and ensure compliance with specific deployment standards or practices.ü Helps enforce policies or guidelines related to resource creation and provisioning methods.üProvides information about resource creation processes, facilitating troubleshooting and analysis if problems arise. By using these tags consistently across resources in a cloud environment, organizations can achieve better resource management, cost allocation, and optimized utilization while making it easier to track, monitor, and govern their infrastructure.

1.2 . Implementation of tags

Below is an example of implementing tags in Azure·      

Department    

For department, we can have the following tags which represent each department in the Azure infrastructure (Finance, Marketing, It, HR)

§ Tag: Finance

§ Tag: Marketing

§ Tag: IT        

§ Tag: HR      ·        

Application    

For Application, we can have the following tags which represent each application deployed in the Azure infrastructure (CRM, Analytics, Staff Management, Logistics and Transportation, Network Monitoring)

§ Tag: CRM      

§ Tag: Analytics

§ Tag: Staff management

§ Tag: Logistics and Transportation

§ Tag: Network Monitoring      

Resource Category

Resource category represents the category of each resource deployed in our Azure infrastructure. For example, azure functions and virtual machines are in the compute category, azure cosmos db and azure sql databse are in database category. etc…

§ Tag: Compute

§ Tag: Database

§ Tag: Storage ·      

Resource Type

Resource type represents the type of each resource deployed. For example Virtual Machine belong to Virtual Machine Type, Storage account belongs to Storage account Type, ….

§ Tag: SQL ·      

Tag: NoSQL ·      

Tag: File Storage ·      

Tag: Virtual Machine ·      

Creation mode

Creation mode represents how the resources were deployed in our Azure infrastructure: manually in the portal, using powershell, bicep, terraform, etc.

§ Tag: Manual     

§ Tag: Bicep       

§ Tag: PowerShell ·     

Environment

Environment represents the environment were resources aree deployed in our Azure infrastructure ( development, Qualification, Pre-production, Production)

§ Tag: development

§ Tag: Qualification

§ Tag: Preproduction

§ Tag: Production · 

Cost Center:

Center cost represents the cost center to which the deployed resource belongs to, for billing and load distribution purposes (IT System ,IT Application , Marketing, Finance , HR ).

§ Tag: IT System

§ Tag: IT Application

§ Tag: Marketing

§ Tag: Finance

§ Tag: HR

Consider the following example of creating a virtual machine.

An azure storage account (Resource Type = Compute, Resource Category = storage) for the IT department (Department = IT) to deploy an application (Application = File Management System) .

This storage account is deployed with PowerShell (creation mode = PowerShell) in the Production environment (Environment = Production) The billing for this machine is taken into account in the IT Delivery budget (Cost center = IT System)

This storage account will have the following tags:

  • Resource type = Storage Account
  • Resource category = Storage
  • Department = IT
  • Application = File Management System
  • Resource creation mode = PowerShell
  • Environment = Production
  • Cost center = IT Delivery

In addition, For greater efficiency outside of working hours, it is possible to automate the shutdown and startup processes of virtual machines, especially in the development environment.

We can do this by selecting virtual machines that have the development tag and running a script that starts or stops these virtual machines.

This makes it easier to optimize costs and manage resources in Azure during downtime.

Let’s take another example of creating an azure storage account (Resource type = Storage Account, Resource category = Storage ) for the Marketing department (Department = Marketing) to deploy a CRM application (Application = CRM Management   . This Storage account is deployed with Bicep (Resource creation mode = Bicep) in the Qualification environment (Environment = Qualification) . The invoicing of this Storage account is taken into account in the Marketing budget (Cost center = Marketing) .

This SQL Server database will have the next tags:

  • Resource type = Storage Account·     
  • Resource category = Storage      
  • Department = Marketing·    
  •  Application = CRM Management   
  • Resource creation mode = Bicep·    
  •  Environment = Qualification·     
  • Cost center = Marketing     

Testing


#variables
$resourceGroupName="tag-demo-rg"
$resourceGroupLocation="westus"
$storageAccountName="tagstdemosync"

# Create a resource group
az group create --location $resourceGroupLocation --name $resourceGroupName

# Create a storage account with tags 
az storage account create `
  --resource-group $resourceGroupName `
  --name $storageAccountName `
  --location $resourceGroupLocation `
  --sku Standard_LRS `
  --kind StorageV2 `
  --tags "Resource type=Storage Account"   `
         "Resource category=Storage"  `
         "Department=IT"   `
         "Application=File Management System"  `
         "Resource creation mode=PowerShell"  `
         "Environment=Production"  `
         "Cost center=IT Delivery"

# Display Tags
az resource list --tag "Department=IT" --query "[].{Type:type, Name:name}" --output table

az resource list --query "[?tags.Department=='IT' && tags.Application=='File Management System'].{Type:type, Name:name}" --output table



# A second example with tags tags Resource type=Storage Account" ,  "Resource category=Storage"  ,Department=Marketing"   , "Application=CRM Management"  , "Resource creation mode=Bicep"  
# "Environment=Qualification"  , "Cost center=Marketing"
$storageAccountName="tagstquasync"

# Create a storage account

az storage account create `
  --resource-group $resourceGroupName `
  --name $storageAccountName `
  --location $resourceGroupLocation `
  --sku Standard_LRS `
  --kind StorageV2 `
  --tags "Resource type=Storage Account"   `
         "Resource category=Storage"  `
         "Department=Marketing"   `
         "Application=CRM Management"  `
         "Resource creation mode=Bicep"  `
         "Environment=Qualification"  `
         "Cost center=Marketing"

Leave a Comment