Reputation: 41
I'm trying to spin up VM with cloud-init using Azure SDK. Script is based on this example: https://github.com/Azure-Samples/virtual-machines-python-manage/blob/master/example.py I have added following:
with open(cloudinit, "r") as cl:
clcont=cl.read()
# CUSTOM_DATA=base64.b64encode(clcont.encode('utf-8')).decode('ascii')
CUSTOM_DATA=clcont
Next in the function create_vm_parameters
added:
'custom-data': CUSTOM_DATA
I have tried following examples:
custom-data
in os_profile
as well as separated block. When trying to spin up vm with az cli
, the cloud-init script works fine.
Do you have any ideas how to make it work with python sdk? Perhaps I am adding it in the incorrect section while creating the vm parameters?
Upvotes: 0
Views: 517
Reputation: 41
Since no one has answer, my colleague solved it.
Saved cloudinit as yaml file, and:
clcont== '\n'.join([
'', yaml.dump(cloudinit), ])
CUSTOM_DATA = base64.b64encode(clcont.encode('utf-8')).decode('latin-1')
And put it in os_profile
: 'custom_data': CUSTOM_DATA,
Upvotes: 3