Search code examples
pythonazureazure-sdk

How to Specify Cloud-Init When Creating A Virtual Machine with the Azure Python Compute SDK


I am looking to run a startup script on a linux virtual machine when I create and start it with the Azure Python SDK. How should I go about doing this?


Solution

  • You can add the cloud-init as the value of the custom_data in the VM os_profile. But as the property shows:

    Specifies a base-64 encoded string of custom data. The base-64 encoded string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum length of the binary array is 65535 bytes.

    Its value should be a base-64 encoded string. You can how to do it from another issue.