Search code examples
azurecloud-init

How to pass cloud-init file locally?


I have been working on windows bash and tried to pass the cloud init file, unfortunately i can not access the app through web, below is the reference..

"https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-automate-vm-deployment"


Solution

  • You can use any editor you wish from “Linux text editors” to create cloud-init.txt file locally.

    I used nano editor to create cloud-init.txt file as follows:

    nano cloud-init.txt

    Copy and paste content mentioned in the document mentioned.

    Ctrl+X to save and press Y;

    enter image description here

    Now use az login to sign-in, if you have not install azure cli 2.0 you may refer “Install Azure CLI 2.0 with apt”.

    az login

    enter image description here

    Now create a VM with –custom-data as follows:

    az vm create --resource-group myResourceGroupAutomate --name myVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys  --custom-data /root/cloud-init.txt
    

    enter image description here

    To allow web traffic to reach your VM, open port 80 from the Internet with az vm open-port:

    az vm open-port --port 80 --resource-group myResourceGroupAutomate --name MyVM
    

    Test web app:

    enter image description here