I have a question regarding accessing custom data from a Azure Linux VM after boot up. I am currently using the Azure GO SDK to programmatically create VMs which are based on CentOS Linux 7.5. For each VM, I am attaching a unique set of environment variables so that the boot up service scripts can access the environment. The custom data is only a set of environment variables, no actual scripts.
In the OS profile, I fill in the base64 encoded string as follows:
OsProfile: compute.OSProfile{
ComputerName: to.StringPtr(p.InstanceName),
AdminUsername: to.StringPtr(p.UserName),
LinuxConfiguration: compute.LinuxConfiguration{
SSH: compute.SSHConfiguration{
PublicKeys: []compute.SSHPublicKey{
{
Path: to.StringPtr(
fmt.Sprintf("/home/%s/.ssh/authorized_keys",
p.UserName)),
KeyData: to.StringPtr(p.SshPublicKey),
},
},
},
},
CustomData: to.StringPtr(base64.StdEncoding.EncodeToString([]byte(p.UserData))),
},
Its not clear to me, how to access the custom data from inside the VM.
In AWS case, we use the instance user data and access the data from the EC2 instance as follows:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html