'Invoke an Azure CLI command that I've created using az vmss run-command create

I've created a command using the Azure CLI like this, that I want to use to pull docker logs from a container running in an Azure Virtual Machine ScaleSet (VMSS):

az vmss run-command create --resource-group "my-resource-group" --instance-id "0" --location "[azure_location_here]" --async-execution false --run-as-user "su" --script "docker logs ab5" --timeout-in-seconds 3600 --run-command-name "myCommandName" --vmss-name "aks-myservice-1234567-vmss"  --output-blob-uri "https://myfileshare.blob.core.windows.net/my-azure-storage-container/log.txt"

I can see the command listed when I use:

az vmss run-command list --subscription "[my_subscription_id]" -g my-resource-group --vmss-name "aks-myservice-1234567-vmss" --instance-id 0

This gives me the following:

[
  {
    "asyncExecution": false,
    "errorBlobUri": null,
    "id": "/subscriptions/[my_subscription_id]/resourceGroups/my_resource_group/providers/Microsoft.Compute/virtualMachineScaleSets/aks-myservice-1234567-vmss/virtualMachines/0/runCommands/myCommandName",
    "instanceView": null,
    "location": "[azure_location_here]",
    "name": "myCommandName",
    "outputBlobUri": "https://myfileshare.blob.core.windows.net/my-azure-storage-container/log.txt",
    "parameters": null,
    "protectedParameters": null,
    "provisioningState": "Succeeded",
    "resourceGroup": "my_resource_group",
    "runAsPassword": null,
    "runAsUser": "su",
    "source": {
      "commandId": null,
      "script": "docker logs ab5",
      "scriptUri": null
    },
    "tags": null,
    "timeoutInSeconds": 3600,
    "type": "Microsoft.Compute/virtualMachineScaleSets/virtualMachines/runCommands"
  }
]

I'm trying to invoke the command using the following:

az vmss run-command invoke -g my-resource-group -n aks-myservice-1234567-vmss --instance-id 0 --command-id myCommandName

This gives me the error:

(NotFound) The entity was not found in this Azure location.

How can I invoke (run) the command that I created in the first step, so that the script docker logs ab5 is run on the VMSS instance? I know how to directly run this script using az vmss run-command invoke, but the output is limited to the first 4096 bytes of the docker log. I'm trying to use az vmss run-command create to set up the script, as that allows me to use the parameter --output-blob-uri, which I'm hoping will allow me to capture the entire Docker log in a file within Azure storage once I invoke the script.

The documentation for az vmss run-command invoke isn't really clear on how a command can be invoked that was created using az vmss run-command create.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source