Set-AzureRmResource Slow for VMs
Description
I'm using the Set-AzureRmResource command in a loop to inherit Resource Group tags down to the inner resources. This is working well, except that it takes 60+ seconds to run the Set-AzureRmResource command against virtual machines. When run against other resources, it takes anywhere from 2 - 10 seconds. The results are very consistent across my entire subscription, which consists of a couple dozen VMs and related resources. The command takes just over a minute when run for a VM and just a few seconds for everything else.
Interestingly, this doesn't happen when the DebugPreference is set to Continue (or with the -Debug switch). In debug mode, the command completes in under 10 seconds.
Script/Steps for Reproduction
#This will take 60+ seconds to run
Set-AzureRmResource -ResourceId "/subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}" -Tag @{TestTag = "TestValue"} -Force
#Measure it by running wrapping it in Measure-Command
Measure-Command { Set-AzureRmResource -ResourceId "/subscriptions/{sub-id}/resourceGroups/{rg-name}/providers/Microsoft.Compute/virtualMachines/{vm-name}" -Tag @{TestTag = "TestValue"} -Force }
#Conversely, this will consistently complete in under 10 seconds:
Measure-Command { Set-AzureRmResource -ResourceId "/subscriptions/{sub-id}/resourceGroups/{rg-name}/providers//Microsoft.Network/publicIPAddresses/{public-ip-name}" -Tag @{TestTag = "TestValue"} -Force }
Module Version
Get-Module -ListAvailable
ModuleType Version Name
---------- ------- ----
Script 0.5.4 Azure.AnalysisServices
Script 0.5.3 Azure.AnalysisServices
Script 0.5.1 Azure.AnalysisServices
Script 0.5.0 Azure.AnalysisServices
Script 0.4.7 Azure.AnalysisServices
Script 0.4.6 Azure.AnalysisServices
Script 0.4.4 Azure.AnalysisServices
Script 0.4.2 Azure.AnalysisServices
Script 0.3.0 Azure.AnalysisServices
Script 0.2.0 Azure.AnalysisServices
Script 4.5.0 Azure.Storage
Script 4.4.0 Azure.Storage
Script 4.3.0 Azure.Storage
Script 4.1.1 Azure.Storage
Script 4.1.0 Azure.Storage
Script 4.0.2 Azure.Storage
Script 3.4.1 Azure.Storage
Script 3.4.0 Azure.Storage
Script 0.6.0 AzurePSDrive
Script 6.8.1 AzureRM
Script 0.6.14 AzureRM.AnalysisServices
Script 6.1.5 AzureRM.ApiManagement
Script 0.1.8 AzureRM.ApplicationInsights
Script 5.1.1 AzureRM.Automation
Script 4.0.10 AzureRM.Backup
Script 4.1.5 AzureRM.Batch
Script 0.14.6 AzureRM.Billing
Script 5.0.5 AzureRM.Cdn
Script 0.9.10 AzureRM.CognitiveServices
Script 5.5.2 AzureRM.Compute
Script 0.3.7 AzureRM.Consumption
Script 0.2.10 AzureRM.ContainerInstance
Script 1.0.10 AzureRM.ContainerRegistry
Script 5.0.3 AzureRM.DataFactories
Script 0.5.10 AzureRM.DataFactoryV2
Script 5.1.4 AzureRM.DataLakeAnalytics
Script 6.1.2 AzureRM.DataLakeStore
Script 4.0.9 AzureRM.DevTestLabs
Script 5.0.4 AzureRM.Dns
Script 0.3.7 AzureRM.EventGrid
Script 0.6.10 AzureRM.EventHub
Script 4.1.8 AzureRM.HDInsight
Script 5.1.3 AzureRM.Insights
Script 3.1.8 AzureRM.IotHub
Script 5.2.1 AzureRM.KeyVault
Script 4.1.4 AzureRM.LogicApp
Script 0.18.5 AzureRM.MachineLearning
Script 0.4.8 AzureRM.MachineLearningCompute
Script 0.2.5 AzureRM.MarketplaceOrdering
Script 0.10.4 AzureRM.Media
Script 6.6.1 AzureRM.Network
Script 5.0.3 AzureRM.NotificationHubs
Script 5.0.6 AzureRM.OperationalInsights
Script 1.0.4 AzureRM.PolicyInsights
Script 4.1.10 AzureRM.PowerBIEmbedded
Script 5.5.1 AzureRM.profile
Script 4.1.8 AzureRM.RecoveryServices
Script 4.4.1 AzureRM.RecoveryServices.Backup
Script 0.2.9 AzureRM.RecoveryServices.SiteRec...
Script 5.0.5 AzureRM.RedisCache
Script 0.3.10 AzureRM.Relay
Script 6.4.2 AzureRM.Resources
Script 0.16.10 AzureRM.Scheduler
Script 4.1.0 AzureRM.ServerManagement
Script 0.6.11 AzureRM.ServiceBus
Script 0.3.12 AzureRM.ServiceFabric
Script 5.0.4 AzureRM.SiteRecovery
Script 4.11.3 AzureRM.Sql
Script 5.0.4 AzureRM.Storage
Script 4.0.10 AzureRM.StreamAnalytics
Script 4.0.5 AzureRM.Tags
Script 4.1.1 AzureRM.TrafficManager
Script 4.0.5 AzureRM.UsageAggregates
Script 5.0.9 AzureRM.Websites
Environment Data
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.228
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17134.228
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
@Tiano2017 @hyonholee Can you take a look?
Cleaning up old issues from 2016 - 2018. Please reopen this issue if it is still a concern.
I tested this morning, and this is still an issue.
#This takes a little over a minute
Measure-Command { Set-AzResource -ResourceId "/subscriptions/xyz-xyz-xyz/resourceGroups/abcdrg/Microsoft.Compute/virtualMachines/myvm01" -Force }
#This takes under 10 seconds
Measure-Command { Set-AzResource -ResourceId "/subscriptions/xyz-xyz-xyz/resourceGroups/abcdrg/Microsoft.Network/networkInterfaces/myvm01-nic" -Force }
I'm running Az.Resources version 1.6.2. @Drewm3 can you please re-open?
Thanks for the update. I have repoened this.
@Tiano2017 is taking a look at this from ARM
@drewm3 and @Tiano2017 - any updates?
@Tiano2017, I believe this is best looked at from the ARM perspective first. Let me know if additional debugging from the compute side is needed.
@migrande I tried the same command but the result I got on a VM resource is: TotalSeconds : 10.1508879. Not sure if it's specific to your subscription. Is it possible to capture your client logs with a -debug option and share that with us?
still no updates, it's always that slow
:bell: Routing this issue to @act-identity-squad.
Set-AzureRmResource is now a retired module. Both the Az.Resources cmdlets and the underlying ARM tagging behavior have changed substantially since 2020. Closing as obsolete. Please open a fresh issue if you can still reproduce the 60s+ delay tagging VMs with Set-AzResource on current Az.Resources