Azure / Azure/azure-cli

VM.osProfile.customData always returns null

Open
#20,870 3 comments 2 reactions 1 assignee Claimed by @zhoxing-ms View on GitHub
act-observability-squad Compute customer-reported feature-request
Dominant language
Python
Stars
4.6k
Forks
3.5k
Avg merge
3d 2h
Merged PRs (30d)
60

Description

## Describe the bug

This is essentially a repost of #5866 with a little bit of additional information.

## To Reproduce

Provision a new Azure VM running Ubuntu 20.04 LTS with a defined `cloud-init` customData.

Log into the newly provisioned VM to verify that the custom data has been run and has had an effect.

Run `az vm show --resource-group groupName --name vmName` and observe that `customData` is null.

## Expected behavior

Running `az vm show --resource-group groupName --name vmName` should include an `osProfile.customData` field containing the base64 encoded custom data used to initialize the VM.

I can confirm that the custom data is run, and that the base64-encoded data is accessible from `/var/lib/waagent/ovf-env.xml` within the VM itself.

## Environment Summary
```
Linux-5.11.0-1022-azure-x86_64-with-glibc2.29
Python 3.8.10
Shell: bash

azure-cli 2.0.81

Extensions:
azure-devops 0.17.0
```

## Additional context

This is almost certainly a service related issue, as it is also visible from the Azure Resource Explorer (https://resources.azure.com/) and when issuing raw requests to the Azure Management API using cURL.

From the Azure Resource Explorer, when viewing the JSON contents of a VM, the `osProfile.customData` key is reliably missing, even though it is included in the documentation tab:

> Specifies a base-64 encoded string of custom data. The base-64 encoded string is decoded to a binary array that is saved as a file on the Virtual Machine. The maximum length of the binary array is 65535 bytes.

For using cloud-init for your VM, see [Using cloud-init to customize a Linux VM during creation](https://docs.microsoft.com/azure/virtual-machines/virtual-machines-linux-using-cloud-init?toc=%2fazure%2fvirtual-machines%2flinux%2ftoc.json)

Likewise the `osProfile.customData` field is also missing when using cURL against the API directly:

`curl 'https://management.azure.com/subscriptions/SUBSCRIPTION_ID/resourceGroups/GROUP_ID/providers/Microsoft.Compute/virtualMachines/VM_NAME?api-version=2021-03-01'`

Apologies if this isn't the right place to report such an issue— if so I'd appreciate pointers on where it might be more appropriate.

Thanks and happy new year!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.