0

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:

  • passed base64, base64 ascii decoded as well as plain script context.
  • provide 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?

2
  • Where do you add the custom-data? Is it in the os_profile? Commented Oct 18, 2018 at 9:24
  • I tried both: in os_profile and on the same level. both didn't work. Commented Oct 19, 2018 at 14:04

1 Answer 1

3

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,

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.