Search code examples
azureazure-resource-managerazure-clicloud-init

Pass parameters to --custom-data Cloud Init script using az cli


Is there a way to pass parameters to the cloud init script? Trying to achieve something like this:

az vm create ... --custom-data myscript.yml param1 param2

Obviously it is possible to use variables from an ARM template like here: https://github.com/Azure/iotedge-vm-deploy/blob/master/cloud-init.txt#L44


Solution

  • I'm afraid you made the mistake. It's not the parameter for the CLI command az vm create, it's a variable of the Azure Template. You can see the variable docs is defined in the template variables block, and of course, you can then use it in the template for the VM property customData.

    Now the CLI command az vm create does not support the parameters for the --custom-data. You can get more details about the cloud-init for Azure VM here.