This repo is for creating a new image version in Azure image gallery from an existing virtual machine.
The configured workflow in Github Actions or the build.sh (if you run it locally) does the following tasks:
- Deallocates the existing VM
- Creates a copy of the managed disk of the existing VM
- Creates a new temporary VM using the copy of the managed disk
- Logon to the temporary VM and runs sysprep
- Deallocates the temporary VM
- Creates a temporary managed Azure Image from the temporary VM
- Creates a new Azure images version in Azure Shared Image Gallery
- Deletes the temporary managed Azure Image
- Deletes the temporary VM
Various variables can be defined in env.sample
Target azure image gallery for example is defined in azure_sig_name
Target azure image definition is defined in azure_sig_image_definition_name
- You need an exisiting VM in Azure. It can be still running or can be deallocated.
- The existing VM needs to have the windows feature
OpenSSH Server
enabled.
More information on enabling OpenSSH Server in Windows - You need an existing Azure shared image gallery
- The Azure image gallery contains already a VM image definition, which matches your VM's generation (V1 or V2).
Step 2: Copy env.sample to .env
using:
The .env
is in the .gitignore list. This ensure that the file never leaves your local drive when you git push
.
cp env.sample .env
Please read the comments in .env
. The should be self explanatory.
Create a new repository secret in Github under Settings > Secrets named envfile
and copy&paste the complete content of your .env
file.
- Goto Actions
- Choose the workflow
generate_new_image_version
- Run the Workflow
generate_new_image_version
Choose Run Workflow and enter corresponding values.
Wait for the workflow to finish and check results.