I created a custom Azure VM command:
$ az vm run-command create --vm-name $VM_NAME --resource-group $RESOURCE_GROUP --location $LOCATION --subscription $SUBSCRIPTION_ID --run-command-name "MyCustomCommand" --script "echo Hello"
I verified it provisioned successfully
$ az vm run-command list --resource-group $RESOURCE_GROUP --vm-name $VM_NAME --location $LOCATION --subscription $SUBSCRIPTION_ID
{
"asyncExecution": false,
"errorBlobUri": null,
"id": "/subscriptions/[subscription-id]/resourceGroups/limonrg/providers/Microsoft.Compute/virtualMachines/limonvm/runCommands/MyCustomCommand",
"instanceView": null,
"location": "SwitzerlandNorth",
"name": "MyCustomCommand",
"outputBlobUri": null,
"parameters": null,
"protectedParameters": null,
"provisioningState": "Succeeded",
"resourceGroup": "limonrg",
"runAsPassword": null,
"runAsUser": null,
"source": {
"commandId": null,
"script": "echo Hello",
"scriptUri": null
},
"tags": null,
"timeoutInSeconds": 0,
"type": "Microsoft.Compute/virtualMachines/runCommands"
}
Then I try to run it and get an error:
$ az vm run-command invoke --command-id "/subscriptions/[subscription_id]/resourceGroups/limonrg/providers/Microsoft.Compute/virtualMachines/limonvm/runCommands/MyCustomCommand" --name $VM_NAME --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID
(NotFound) The entity was not found in this Azure location.
Code: NotFound
Message: The entity was not found in this Azure location.
Same thing if I use the command name instead of the entire id:
$ az vm run-command invoke --command-id MyCustomCommand --name $VM_NAME --resource-group $RESOURCE_GROUP --subscription $SUBSCRIPTION_ID
NotFound) The entity was not found in this Azure location.
Code: NotFound
Message: The entity was not found in this Azure location.
What am I doing wrong? Unfortunately Azure Docs do not provide a sample for custom commands.