Chapter 2. Preparing and uploading VHD images to Microsoft Azure
You can create custom images and update them, either manually or automatically, on the Microsoft Azure cloud by using RHEL image builder.
2.1. Preparing to upload Microsoft Azure VHD images manually Copy linkLink copied to clipboard!
To create a VHD image that you can manually upload to the Microsoft Azure cloud, you can use RHEL image builder.
Prerequisites
- You must have a Microsoft Azure resource group and storage account.
-
You have Python installed. The
AZ CLItool depends on Python.
Procedure
Import the Microsoft repository key:
$ sudo rpm --import https://packages.microsoft.com/keys/microsoft-2025.ascCreate a
packages-microsoft-com-prodrepository:[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/packages.microsoft.com/rhel/10/prod/ enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.ascInstall Microsoft Azure CLI. The downloaded version of the Microsoft Azure CLI package can vary depending on the currently available version.
$ sudo dnf install azure-cliRun Microsoft Azure CLI:
$ az loginThe terminal shows the following message:
Note, we have launched a browser for you to login. For old experience with device code, use az login --use-device-code. Then, the terminal opens the Login from where you can log in.NoteIf you are running a remote (SSH) session, the login page link does not open in the browser. In this case, you can copy the link to a browser and log in to authenticate your remote session. To sign in, use a web browser to open the Login page and enter the device code to authenticate.
List the keys for the storage account in Microsoft Azure and make note of the value
key1from the output of the previous command.$ az storage account keys list --resource-group <resource_group_name> --account-name <account_name>Replace
resource-group-namewith the name of your Microsoft Azure resource group andstorage-account-namewith the name of your Microsoft Azure storage account.To list the available resources using the following command:
$ az resource list
Create a storage container:
$ az storage container create --account-name <storage_account_name> \ --account-key <key1_value> --name <storage_account_name>Replace
storage-account-namewith the name of the storage account.
2.2. Manually uploading VHD images to Microsoft Azure cloud Copy linkLink copied to clipboard!
Create your customized virtual hard disk (VHD) image, and manually upload it to the Microsoft Azure cloud. When you create a .vhd image by using the CLI, RHEL image builder writes temporary files to the /var subdirectory.
The partition and filesystem configurations that you define in your image blueprint determine the size of the resulting .vhd image. If you allocate insufficient storage,the process might fail with a “No space left on device” error. This occurs, for example, if the available space on the /var partition is smaller than the total space required for the image build. To prevent the .vhd image creation from failing, verify that the /var subdirectory has at least 15 to 20 GB of free space.
Prerequisites
- Your system must be set up for uploading Microsoft Azure VHD images.
- Your Azure access key storage account.
Procedure
Create a
azure.tomlblueprint, and add the following information to it:provider = "azure" [settings] storageAccount = "<your-storage-account-name>" storageAccessKey = "<storage-access-key-you-copied-in-the-Azure-portal>" container = "<your-storage-container-name>"Build the image, passing the following arguments:
$ image-builder build <your-blueprint> vhd <your-image-key> azure.tomlReplace <your-image-key> with the name of the image that you want.
Push the image to Microsoft Azure and create an instance from it:
$ az storage blob upload --account-name <account-name> --container-name <container-name> --file <image-disk>.vhd --name image-disk.vhd --type pageAfter the upload to the Microsoft Azure Blob storage completes, create a Microsoft Azure image from it. Because the images that you create with RHEL image builder generate hybrid images that support both the
V1 = BIOSandV2 = UEFIinstance types, you can specify the--hyper-v-generationargument. The default instance type isV1.$ az image create --resource-group resource_group_name --name image-disk.vhd --os-type linux --location location \ --source https://$account_name.blob.core.windows.net/container_name/image-disk.vhd - Running
Verification
Create an instance either with the Microsoft Azure portal, or a command similar to the following:
$ az vm create --resource-group resource_group_name --location location --name vm_name --image image-disk.vhd(--admin-username azure-user --generate-ssh-keys* - Running-
Use your private key by using SSH to access the resulting instance. Log in as
azure-user. This username was set on the previous step.
2.3. Creating and automatically uploading VHD images to Microsoft Azure cloud Copy linkLink copied to clipboard!
By using RHEL image builder, you can create .vhd images, which will be automatically uploaded to an Azure Blob Storage in the Microsoft Azure Cloud service provider.
Prerequisites
- You have root access to the system.
- You have access to the RHEL image builder interface of the RHEL web console.
- You created a blueprint. See Creating a RHEL image builder blueprint in the web console interface.
- You have a Microsoft Storage Account created.
- You have a writable Blob Storage prepared.
Procedure
- In the RHEL image builder dashboard, select the blueprint you want to use.
- Click the Images tab.
Click Create Image to create your customized
.vhdimage.The Create image wizard opens.
-
Select
Microsoft Azure (.vhd)from the Type drop-down menu list. - Check the Upload to Azure checkbox to upload your image to the Microsoft Azure Cloud.
- Enter the Image Size and click Next.
-
Select
On the Upload to Azure page, enter the following information:
On the Authentication page, enter:
- Your Storage account name. You can find it on the Storage account page in the Microsoft Azure portal.
- Your Storage access key: You can find it on the Access Key Storage page.
- Click Next.
On the Authentication page, enter:
- The image name.
- The Storage container. It is the blob container to which you will upload the image. Find it under the Blob service section, in the Microsoft Azure portal.
- Click Next.
On the Review page, click Create. The RHEL image builder and upload processes start.
Access the image you pushed into Microsoft Azure Cloud.
- Access the Microsoft Azure portal.
- In the search bar, type "storage account" and click Storage accounts from the list.
- On the search bar, type "Images" and select the first entry under Services. You are redirected to the Image dashboard.
- On the navigation panel, click Containers.
-
Find the container you created. Inside the container is the
.vhdfile you created and pushed by using RHEL image builder.
Verification
Verify that you can create a VM image and launch it.
- In the search bar, type images account and click Images from the list.
- Click +Create.
- From the dropdown list, choose the resource group you used earlier.
- Enter a name for the image.
- For the OS type, select Linux.
- For the VM generation, select Gen 2.
- Under Storage Blob, click Browse and click through the storage accounts and containers until you reach your VHD file.
- Click Select at the end of the page.
- Choose an Account Type, for example, Standard SSD.
- Click Review + Create and then Create. Wait a few moments for the image creation.
To launch the VM, follow the steps:
- Click Go to resource.
- Click + Create VM from the menu bar on the header.
- Enter a name for your virtual machine.
- Complete the Size and Administrator account sections.
Click Review + Create and then Create. You can see the deployment progress.
After the deployment finishes, click the virtual machine name to retrieve the public IP address of the instance to connect by using SSH.
- Open a terminal to create an SSH connection to connect to the VM.