New Question

How to use cloudbase-init for windows azure instance

asked 2020-01-15 20:00:11 +0200

bsharma-2104 gravatar image

updated 2020-01-22 12:46:25 +0200

avladu gravatar image

I am trying to use cloudbase-init for windows azure instance. I created image from a machine with cloudbase-init enabled but can't figure out how to use this image to leverage cloudbase-init features like setting up hostname while starting another instance from this image. Trying out this from azure portal following this tutorial. Any help would be appreciated.

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2020-01-30 09:12:25 +0200

bsharma-2104 gravatar image

Hi. I am able to start cloudbase init on windows 2012 instance and try out different cloudbase init features. But, few challenges I am facing. 1. I want to run one batch file using cloudbase init Userdata plugin. This batch file is present inside my instance. How do I run this batch file specifying details in cloud config script? Tried something like this: runcmd <path of="" batch="" file="" in="" image="">\test.bat

This doesn't work. How do I achieve this?

  1. I want to create a custom Windows 2012 R2 image with cloudbase init enabled using custom cloud config files. Which preexisting template to use? Can you provide more details on how to achieve this using I can do this manually but my requirement is to achieve the same via code or azure cli.

  2. I want to use cloudbase init password plugin to set some random password. But, the challenge is how do I retrieve this password. Azure doesn't provide any APIs to retrieve this password.

Waiting for your reply on above questions.

edit flag offensive delete link more


Hello, Here is an example configuration for Cloudbase-Init for Azure: Azure already provides the option to set a password for a custom user when you create the VM. Cloudbase-Init will set the password.

avladu gravatar imageavladu ( 2020-01-31 19:55:17 +0200 )edit

Thanks for the answer. I want to use Cloudbase-Init feature where it sets random password using inject_user_password = false. In my case, it sets the password but I don't know how to retrieve that password. Also, couuld you please answer my initial question related to running batch file?

bsharma-2104 gravatar imagebsharma-2104 ( 2020-02-03 07:05:09 +0200 )edit

On the password issue, Azure does not have an API where cloudbase-init can post the password (like OpenStack does, for example). You can only use the feature that Azure provides you: creating a user with a password when you create the instance.

avladu gravatar imageavladu ( 2020-02-03 12:03:41 +0200 )edit

Running commands is currently supported for the beta version of cloudbase-init. Please check for the supported cloud-config features.

avladu gravatar imageavladu ( 2020-02-03 12:05:01 +0200 )edit

I tried using runcmd as suggested in the above doc. But, it comes as as unsupported command. I am using cloudbase-init beta version only. I am using this command: runcmd: - 'C:\\myBatchFile.bat'

bsharma-2104 gravatar imagebsharma-2104 ( 2020-02-11 08:23:28 +0200 )edit

answered 2020-01-22 12:53:03 +0200

avladu gravatar image


The tutorial you followed is a great point to start. At what step did you encounter issues?

The image can also be created in your own environment using with a custom cloudbase-init config file (you can use the ones from the tutorial), then upload the VHD to Azure. Thank you,


edit flag offensive delete link more


I couldn't post entire text here. So, have asked follow-up questions I have in the above answer comment. Please check.

bsharma-2104 gravatar imagebsharma-2104 ( 2020-01-30 09:13:50 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2020-01-15 20:00:11 +0200

Seen: 1,499 times

Last updated: Jan 30 '20