How to tag resources in Azure
This article has not been completed yet. However, it may already contain helpful Information and therefore it has been published at this stage.
The GUI - Way:
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
The PowerShell - Way:
Connect to Azure:
Query and choose a subscription:
# Query and choose a Subscription
$Subscription = Get-AzSubscription | Out-GridView -PassThru
# $Subscription
Select-AzSubscription $Subscription
Dealing with tags inside Azure:
# List tags and their number of occurences
Get-AzTag
# Get all Ressources with a specific Tagdefinition
Get-AzResource -TagName <Tagdefintion>
# Get Tags of a specific Ressource
(Get-AzResource -Name <Ressourcename>).Tags
# Get all Ressource Names with a specific Tag Value
(Get-AzResource -Tag @{<Tagdefintion>="<Tagvalue>"}).Name
# Get a reference to an Azure resource
$r = Get-AzResource -ResourceName <Ressourcename> -ResourceGroupName <Ressourcegroupname>
# Retrieve existing resource tags, if any
$tags = (Get-AzResource -Name <Ressourcename>).Tags
# Add new tags to exiting tags
$tags += @{<Tagdefintion1>="<Tagvalue1>"; <Tagdefintion2>="<Tagvalue2>"}
# Write new tags to an Azure resource
Set-AzResource -ResourceId $r.Id -Tag $tags -Force
#(Get-AzResource -Name <Ressourcename>).Tags
# Restore last status
Set-AzResource -Tag @{<Tagdefintion>="<Tagvalue>"} -ResourceId $r.id -Force
#(Get-AzResource -Name <Ressourcename>).Tags