Azure - cloud-init 25.1.2 documentation (original) (raw)

View this page

Toggle table of contents sidebar

This datasource finds meta-data and user-data from the Azure cloud platform.

The Azure cloud platform provides initial data to an instance via an attached CD formatted in UDF. This CD contains a ovf-env.xml file that provides some information. Additional information is obtained via interaction with the “endpoint”.

IMDS

Azure provides the instance metadata service (IMDS), which is a REST service on 169.254.169.254 providing additional configuration information to the instance. Cloud-init uses the IMDS for:

Configuration

The following configuration can be set for the datasource in system configuration (in /etc/cloud/cloud.cfg or/etc/cloud/cloud.cfg.d/).

The settings that may be configured are:

Configuration for the datasource can also be read from a dscfg entry in the LinuxProvisioningConfigurationSet. Content in dscfg node is expected to be base64 encoded YAML content, and it will be merged into the'datasource: Azure' entry.

An example configuration with the default values is provided below:

datasource: Azure: apply_network_config: true apply_network_config_for_secondary_ips: true data_dir: /var/lib/waagent disk_aliases: ephemeral0: /dev/disk/cloud/azure_resource

User-data

User-data is provided to cloud-init inside the ovf-env.xml file.Cloud-init expects that user-data will be provided as a base64 encoded value inside the text child of an element named UserData orCustomData, which is a direct child of theLinuxProvisioningConfigurationSet (a sibling to UserName).

If both UserData and CustomData are provided, the behaviour is undefined on which will be selected. In the example below, user-data provided is 'this is my userdata'.

Example:

wa:ProvisioningSection wa:Version1.0 LinuxProvisioningConfiguration myHost myuser dGhpcyBpcyBteSB1c2VyZGF0YQ=== eyJhZ2VudF9jb21tYW5kIjogWyJzdGFydCIsICJ3YWxpbnV4YWdlbnQiXX0= true 6BE7A7C3C8A8F4B123CCA5D0C2F1BE4CA7B63ED7 this-value-unused

HostName

When the user launches an instance, they provide a hostname for that instance. The hostname is provided to the instance in the ovf-env.xml file asHostName.

Whatever value the instance provides in its DHCP request will resolve in the domain returned in the ‘search’ request.

A generic image will already have a hostname configured. The Ubuntu cloud images have ubuntu as the hostname of the system, and the initial DHCP request on eth0 is not guaranteed to occur after the datasource code has been run. So, on first boot, that initial value will be sent in the DHCP request and that value will resolve.

In order to make the HostName provided in the ovf-env.xmlresolve, a DHCP request must be made with the new value. Cloud-inithandles this by setting the hostname in the datasource’s get_data method via hostname $HostName, and then bouncing the interface. This behaviour can be configured or disabled in the datasource config. See ‘Configuration’ above.