Skip to content

Instantly share code, notes, and snippets.

@jkav58
Last active December 7, 2023 16:32
Show Gist options
  • Save jkav58/1a7d80937d82175b5d567e5b135c51bd to your computer and use it in GitHub Desktop.
Save jkav58/1a7d80937d82175b5d567e5b135c51bd to your computer and use it in GitHub Desktop.
Master list of Azure resource Tags

Azure Resource Master Tag List

Azure 🚧

Tags

Tag Format Values Notes
* CreatedOn MM/DD/YYYY 01/31/1900
* CreatedBy User Name Name
* BusinessUnit
* SupportGroup String SNOW List
ApplicationName String Working Need to get a list of appropriate valuies
IAC String Y/N Terraform or other means of deployment/management
BusinessOwner User Name Jeff Truman
TechnicalContact User Name Jeff Truman
Criticality Range 1 through 4 1,2,3,4

VM 💻

VM Specific Tags - in addition to mater tag list

Tag Format Values Notes
PatchingWindow HH:MM to HH:MM 03:00 AM to 07:00 AM
PatchingDOW Letter(s) of Day MTWTFSS

AKS 🐳

List based on tags returned by general query.

Tag Format Values Notes
aks-managed-cluster-name Working
aks-managed-cluster-rg Working
aks-managed-createOperationID Working
aks-managed-creationSource Working
aks-managed-kubeletIdentityClientID Working
aks-managed-operationID Working
aks-managed-orchestrator Working
aks-managed-poolName Working
aks-managed-resourceNameSuffix Working
aks-managed-type Working
ingress-for-aks-cluster-id Working

Code Sampleas

Adding base required tags to Resource (Virtual Machine):

$tags = @{
    "CreatedOn"        = "10/14/2021"
    "Criticality"      = "2" 
    "Application"      = "Application Name"
    "BusinessOwner"    = "Full Name seperate names with /"
    "TechnicalContact" = "Full Name"
    "PatchingWindow"   = "Patching Time Window"
    "PatchingDOW"      = "Days of the week Patches can be applied like MTWTFSS"
    "Compliance"       = "Y"
    "Environment"      = "Production"
    "IAC"              = "N"
}
$res = Get-AzResource -Name servername -ResourceType Microsoft.Compute/virtualMachines
New-AzTag -ResourceId $res.id -Tag $tags

Use OSDisk to estimate the CreatedOn tag for a VM

Set-Azcontext -Subscription SubscriptionName | Out-Null
$vms = Get-AzVM
$tagName = 'CreatedOn'
ForEach ($vm in $vms) {
    $dskInfo = get-azdisk -Name $vm.StorageProfile.OsDisk.Name
    $tagValue = '{0:MM/dd/yyyy}' -f $dskInfo.TimeCreated
    $vm.Name
    If ($vm.tags.Keys -contains $tagName) {
        "`tTag Exists"
    }
    Else {
        "`tWill set CreatedOn Tag for {0} on {1}" -f $vm.Name, $tagValue
        $vm.Tags.Add($tagName, $tagValue)
        Set-AzResource -ResourceId $vm.Id -Tag $vm.tags -Force
    }
}
@jkav58
Copy link
Author

jkav58 commented Sep 14, 2022

Working on generic master list.

Other resources such as AKS can include resource specific tags

@jkav58
Copy link
Author

jkav58 commented Oct 25, 2022

Should Owner be renamed to BusinessOwner or treat them seperate?

@jkav58
Copy link
Author

jkav58 commented Nov 3, 2022

Updates based on Server List recently submitted

@jkav58
Copy link
Author

jkav58 commented Nov 4, 2022

Added code snippets

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment