New Question

Revision history [back]

click to hide/show revision 1
initial version

cloudbase-init config script works inconsistently using azure shared gallery image and azure java client

I have created a windows 2012 R2 azure image with cloudbase-init installed. My intention is to run a script while starting any new VM instance using this image. My cloud config script contains powershell script basically starting with #ps1sysnative. This has been working fine for a while now.

I have moved my azure base image to shared image gallery. Now, when I am creating an instance using the complete image url of latest image present in shared image gallery, I run into one issue. I am passing the same cloud config script. But, what is happening is that I can start new machine with cloud config script executed during startup while doing so using azure cli but while making create instance call using azure java client (basically method https://docs.microsoft.com/en-us/java/api/com.microsoft.azure.management.compute.VirtualMachine.DefinitionStages.WithOS.withWindowsCustomImage?view=azure-java-stable) and passing cloud config using https://docs.microsoft.com/en-us/java/api/com.microsoft.azure.management.compute.virtualmachine.definitionstages.withfromimagecreateoptionsmanaged.withcustomdata?view=azure-java-stable, at time cloudbase-init runs the cloud config powershell script but after a while it is not running this script, that custom data is getting dumped into azure machine as customdata.bin. All cofiguration is same and the same flow works if I give the base image id and not the one present in shared gallery.

Cloud-config script is something like this:

ps1_sysnative

$example = ‘test’

(Get-Content -Path C:\testData) |   ForEach-Object {$_ -Replace ‘{example}‘, $example} |     Set-Content -Path C:\testData

Not sure why this weird behaviour when using shared gallery image and azure java client. I am not making any changes but running into this weird behaviour. Kindly assist.

click to hide/show revision 2
None

cloudbase-init config script works inconsistently using azure shared gallery image and azure java client

I have created a windows 2012 R2 azure image with cloudbase-init installed. My intention is to run a script while starting any new VM instance using this image. My cloud config script contains powershell script basically starting with #ps1sysnative. This has been working fine for a while now.

I have moved my azure base image to shared image gallery. Now, when I am creating an instance using the complete image url of latest image present in shared image gallery, I run into one issue. I am passing the same cloud config script. But, what is happening is that I can start new machine with cloud config script executed during startup while doing so using azure cli but while making create instance call using azure java client (basically method https://docs.microsoft.com/en-us/java/api/com.microsoft.azure.management.compute.VirtualMachine.DefinitionStages.WithOS.withWindowsCustomImage?view=azure-java-stable) and passing cloud config using https://docs.microsoft.com/en-us/java/api/com.microsoft.azure.management.compute.virtualmachine.definitionstages.withfromimagecreateoptionsmanaged.withcustomdata?view=azure-java-stable, at time cloudbase-init runs the cloud config powershell script but after a while it is not running this script, that custom data is getting dumped into azure machine as customdata.bin. All cofiguration is same and the same flow works if I give the base image id and not the one present in shared gallery.

Cloud-config script is something like this:

ps1_sysnative

#ps1_sysnative

$example = ‘test’

‘test’ (Get-Content -Path C:\testData) |   ForEach-Object {$_ -Replace ‘{example}‘, $example} |     Set-Content -Path C:\testData

C:\testData

Not sure why this weird behaviour when using shared gallery image and azure java client. I am not making any changes but running into this weird behaviour. Kindly assist.