Beware! I’m a smidge new to Azure and only recently started fooling around with the template deployment functions. That said… even though it requires quite a shift going from manpages to Azure technical propaganda… it appears ARM templates are fairly straight forward after some initial demystification.
When I went to download my template after using the Azure portal to set up a virtual machine deployment I was a bit dismayed to see that the customData I had included as a cloud-init compatible
user-data.txt data had somehow evaporated and not made it in to the
template.json or the
Turns out this isn’t a very common scenario. So lets get right to it.
First off your downloaded
template.json for a virtual machine will(should) already contain the variable definition for
customData under the root
osProfile key further down the file you will(should) also see the
customData placement and code to include the parameter.
Assuming you are using the CLI tools provided for Linux/MacOS and not Powershell you can now run the following to include your
customData during deployment by way of the magic shell backticks and the
base64 tool set to 0 (disabled) wrapping width.
az deployment group create --resource-group Development --template-file template.json --parameters @parameters.json --parameters customData="`base64 -w 0 cloud-init`"