J00MZ
J00MZ

Reputation: 715

Individually tag instance in Azure VMSS

Is it possible to individually tag a specific vm instance in a scale set?

Something like this command:

az resource tag --tags "name=hostname.example.com ip=10.0.0.10" --id "/subscriptions/{SUBSCRIPTION_ID}/resourceGroups/{RESOURCE_GROUP}/providers/Microsoft.Compute/virtualMachineScaleSets/{SCALESET_ID}/{SCALESET_INSTANCE}"

SCALESET_INSTANCE is what I get when querying the instance metadata service as follows:

curl -s -H Metadata:true "http://169.254.169.254/metadata/instance/compute/name?api-version=2017-08-01&format=text"

However the response I get is:

az resource: error: argument --ids: invalid ResourceId value: <FULL_ID_PATH>

Tried using:

 az resource tag -g {RESOURCE_GROUP} --resource-type "Microsoft.Compute/virtualMachines" -n {SCALESET_INSTANCE}

But no luck either, response is:

The Resource 'Microsoft.Compute/virtualMachines/{SCALESET_INSTANCE} under resource group '{RESOURCE_GROUP}' was not found.

Upvotes: 0

Views: 2195

Answers (1)

Nancy Xiong
Nancy Xiong

Reputation: 28204

It's impossible to individually tag instance in Azure VMSS as there is no resource type for VMSS instance, just for the type of Microsoft.Compute/virtualMachineScaleSets.

enter image description here

About the az resource tag command: az resource tag --tags vmlist=vm1 --id /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/xxxxxxx, the --id is used for using a resource identifier which is different from instance metadata service.

Overall, Azure virtual machine scale sets let you create and manage a group of identical, load balanced VMs. It works as an entirety, it seems that we do not need to add the tags for the individual instances.

Upvotes: 1

Related Questions