2020-04-29

az cli replace VMSS NSG

Let's show you some Azure Cloud settings change. It took me a while to make it work some you might appreciate it as a ready-made command(s).

If you don't like the existing network security group object linked with your virtual machine scale set, you can change it by using set command replacing value there with new id. There is no separate az vmss update command for it.

used variables:
  • $subscriptionId
  • $resourceGroup
  • $vmssName
  • $nsgNameNew
az cli command:
  • az vmss update --name $vmssName -g $resourceGroup --set virtualMachineProfile.networkProfile.networkInterfaceConfigurations[0].networkSecurityGroup.id=/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.Network/networkSecurityGroups/$nsgNameNew
You need to refresh all nodes in VMSS before you can use that new NSG rules or delete old NSG object. You can do it by command
  • az vmss update-instances --instance-ids '*' --name $vmssName --resource-group $resourceGroup --output none --no-wait
or by portal =>  Virtual machine scale set => Scaling => Manual scale => Instance count => 0 and later increasing again. Deallocating VMSS is not enough.

I hope it helped.

Žádné komentáře :

Okomentovat

Dotaz, připomínka, oprava?
(pokud máte problém s vložením příspěvku, vyzkoušejte to v prohlížeči Chrome)