Custom Script Extension with Cloud Init

Shola Lawani 531 Reputation points Microsoft Employee
2021-06-23T01:25:11.803+00:00

Hello Experts
For some good reasons I need to have a cloud-init process and a custom script extension on a VMSS. The cloud-init process is intended to bootstrap base VM configuration such as hardening tools and son on while the custom script is meant to deploy application specific code.

My question is if I both in which sequence do they run? does the cloud-init process runs first and the custom script extension runs after?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
7,190 questions
Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
352 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SRIJIT-BOSE-MSFT 4,331 Reputation points Microsoft Employee
    2021-06-23T09:17:26.243+00:00

    anonymous user , Thank you for your question.

    cloud-init configures a virtual machine (VM) or virtual machine scale sets at provisioning time in Azure. These cloud-init configurations are run on first boot once the resources have been provisioned by Azure. [Reference]

    Please see Cloud-int boot stages (processing configuration) for more information.

    Once the Azure Linux VM agent is installed and the VM is running, then CustomScript uses the following algorithm to run a script:

    1. assert the length of the script's value does not exceed 256 KB.
    2. base64 decode the script's value
    3. attempt to gunzip the base64 decoded value
    4. write the decoded (and optionally decompressed) value to disk (/var/lib/waagent/custom-script/#/script.sh)
    5. execute the script using _/bin/sh -c /var/lib/waagent/custom-script/#/script.sh.

    [Reference]

    ----------

    Hope this helps!

    Please "Accept as Answer" if it helped, so that it can help others in the community looking for help on similar topics.

    0 comments No comments