-
Print
-
DarkLight
The below video will give you an overview of Tag Inheritance and how you can use it with Turbo360.
Many organizations have a limited implementation of their tagging strategy. In the Azure Portal there is an option to apply tag inheritance which means that when the billing data is emitted then it will allow you to include inherited tags on the billing data.
This means you can apply tags at the subscription level or resource group level and the resource billing data will include these tags. This makes it a lot easier to improve your tagging strategy quickly.
A few things to think about with Tag Inheritence:
If you already have tags on resources and don’t override them, then you may already have values in some cases that you aren’t expecting
If you do override the tags then any settings applied at resource level will be overridden by the subscription level tags.
Information
Please be aware at this time the Azure Tag Inheritance feature only applies tag inheritance to new usage data moving forwards starting within 8-24 hours. It does not currently apply this retrospectively to old data
How does this help me with Turbo360?
In Turbo360, you can use tags as filters within the tree view or also within individual graphs, but one of the features I like the most is where you can use the rules on a cost management group to generate a sub-tree, which then shows your costs in relation to some groupings that make sense for you.
The Azure Tag Inheritance feature can work well in combination with our Tree View to generate nodes to help you work forward with cost data.
In the below image, you can see where I am using a parent/child model of:
Department
Product
Environment
In the image below, you can see where the inherited tags were used to generate the tree view for Turbo360. I now have nodes for each of these combinations, which are easy for me to work with.
How can I update tags for subscriptions in bulk?
The script below is an example of the one we used internally to update the tags on our Azure subscriptions in bulk so that we had some subscription-level tags that we could inherit.
I hope you will be able to use it as a base to apply some of the rules you need to apply tags to your subscriptions more quickly.
$tenantId = ""
<#
Step 1: Replace the tenantId with your tenantId
Step 2: Install the Az module
Install-Module -Name Az -AllowClobber -Force
Step 3: Connect to Azure using the below command
Connect-AzAccount -TenantId $tenantId
Note:
If you want the script to fail on first error use the below command at the beginning of the script
$ErrorActionPreference = "Stop"
#>
<# Get your subscriptions then loop through then updating the script level tags #>
$subscriptions = Get-AzSubscription -TenantId $tenantId
foreach($subscription in $subscriptions){
Write-Host "Subscription: $($subscription.Name)" -ForegroundColor Green
Write-Host "SubscriptionId: $($subscription.id)" -ForegroundColor Green
<# Default tags we want to apply in this exercise #>
$tags = @{
"Department" = ""
"Product" = ""
"Environment" = ""
"ServiceOwner" = ""
"TechnicalOwner" = ""
}
$subscriptionId = $subscription.id
$subscriptionNameLowerCase = $subscription.Name.ToLower()
Write-Host "Subscription Name (lower case): $($subscriptionNameLowerCase)"
<#
You could add your own rules here for department, product, service owner, environment
an example of environment is given below
#>
if($subscriptionNameLowerCase.Contains("demo")){
$tags["Environment"] = "Demo"
}
if($subscriptionNameLowerCase.Contains("poc")){
$tags["Environment"] = "Proof-Of-Concept"
}
if($subscriptionNameLowerCase.Contains("dev")){
$tags["Environment"] = "Development"
}
if($subscriptionNameLowerCase.Contains("qa")){
$tags["Environment"] = "QA"
}
if($subscriptionNameLowerCase.Contains("test")){
$tags["Environment"] = "Test"
}
if($subscriptionNameLowerCase.Contains("stag")){
$tags["Environment"] = "Staging"
}
if($subscriptionNameLowerCase.Contains("stg")){
$tags["Environment"] = "Staging"
}
if($subscriptionNameLowerCase.Contains("prod")){
$tags["Environment"] = "Production"
}
if($subscriptionNameLowerCase.Contains("prd")){
$tags["Environment"] = "Production"
}
<# Write Tags to console before applying #>
Write-Host "Tags to be applied:"
foreach ($h in $tags.GetEnumerator()) {
Write-Host "`t$($h.Name): $($h.Value)"
}
Update-AzTag -ResourceId "subscriptions/$subscriptionId" -Tag $tags -Operation Merge
Write-Host ""
}
Write-Host "Subscription Tags updated successfully" -ForegroundColor Green