

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to import the tags in Azure?
In the previous article, we have seen that we can export the Azure resource tags in the JSON file or CSV format. There are some cases when you rebuild your resource and you might need to restore your tags or someone with the authorized person to have azure resource access and he accidentally deletes the tags and we need to restore them. In such cases, if we have the tags backup already we can import them to the resources.
In the below example, we suppose we have the Azure VM tags backup stored in the CSV file format and after rebuilding it we need to add tags again or consider the other scenario that we need to copy the existing VM tags to the newly built VM.
We have an existing azure VM TestVM and we will export its tags first to the Tags.csv file with the below commands.
Get-AzVM -VMName TestVM | Select -ExpandProperty Tags | ConvertTo-Json | ConvertFrom-Json | Export-Csv C:\Temp\Tags.csv -NoTypeInformation
We have once the tags are stored in a CSV file we can import them.
PS C:\> Import-Csv C:\Temp\tags.csv For Patching_Day Application Owner --- ------------ ----------- ----- Ansible Sunday SecretTag Chirag
We need to apply the above tags to the new VM TestMachine2k16. So we will use the below commands.
$tags = Import-Csv C:\temp\Tags.csv $vm = Get-AzVM -VMName TestMachine2k16 foreach($head in $tags.psobject.Properties.Name){ $newtag = @{$head = $tags.$head} Update-AzTag -ResourceID $vm.id -Tag $newtag -Operation Merge -Verbose }
- Related Questions & Answers
- How to Export the azure VM tags using PowerShell?
- How to get the applied azure resource tags using PowerShell?
- How to delete all the tags of the azure resource using PowerShell?
- How can I import modules for a Python Azure Function?
- How to list the Azure VMs using Azure CLI in PowerShell?
- How to deallocate the Azure VM using Azure CLI in PowerShell?
- How to start the Azure VM using Azure CLI in PowerShell?
- How to stop the Azure VM using Azure CLI in PowerShell?
- How to restart the Azure VM using Azure CLI in PowerShell?
- How to resize the Azure VM using Azure CLI in PowerShell?
- How to connect to the Azure subscription using Azure CLI in PowerShell?
- How to get the Azure resource group using Azure CLI in PowerShell?
- How to get the Azure VM Size using Azure CLI in PowerShell?
- How to get the Azure VM username using Azure CLI in PowerShell?
- How to delete the azure blob (File) using Azure CLI in PowerShell?