Hi all,
I am creating a script which tags VM's based on responses of a powershell form (it tags start and stop times for use with automation).
I am finding the performance when running from powershell on my local computer is pretty pants. It takes around 1min 15 seconds to run the update-azvm to update the tag values on the target VM.
At the start of the script, I clear off all the tags relating to start stop times, then apply the changes with update-azvm. I've copied this part of the code as its the shortest bit:
$VMName = "vmstartstoptest"
$RGName = "RG-NP-UKS-STARTSTOPTEST"
$ScheduleTags = "Daily_Start",`
"Daily_Stop",`
"Weekday_Start",`
"Weekday_Stop",`
"Weekend_Start",`
"Weekend_Stop",`
"Monday_Start",`
"Monday_Stop",`
"Tuesday_Start",`
"Tuesday_Stop",`
"Wednesday_Start",`
"Wednesday_Stop",`
"Thursday_Start",`
"Thursday_Stop",`
"Friday_Start",`
"Friday_Stop",`
"Saturday_Start",`
"Saturday_Stop",`
"Sunday_Start",`
"Sunday_Stop"
$vm = Get-AzVM -ResourceGroupName $RGName -Name $VMName
foreach ($SchTag in $ScheduleTags)
{
$TagExists = $vm.tags.ContainsKey($SchTag)
if ($TagExists -eq 'True')
{
$vm.tags.remove($SchTag)
}
}
Update-AzVM -ResourceGroupName $RGName -VM $vm -tag $vm.tags | Out-Null
If I run this same code from within Azure Powershell, its still not quick, but completes in around 30 seconds, so its well over twice as quick.
I am on a decent internet connection so connection speed shouldn't be an issue.
Does anyone know why the update-vm command is so slow from a powershell session running on a remote computer?
Thanks in advance
Dave