3.10. Uploading a VHD image to Azure Blob storage
By using the Microsoft Azure Blob storage, you can manage the VHD file and create a custom Azure image.
The exported storage connection string does not persist after a system reboot. If any of the commands in the following steps fail, export the connection string again. See Configuring the Azure resources for a RHEL image to obtain and export a connection string.
Prerequisites
- You have already configured Azure resources.
Procedure
Upload the
VHDfile to the storage container:$ az storage blob upload \ --account-name _<storage_account_name> --container-name _<container_name> \ --type page --file _<path_to_vhd> --name _<image_name>.vhdExample:
$ az storage blob upload \ --account-name azrhelclistact --container-name azrhelclistcont \ --type page --file ~/Downloads/rhel-image-10.vhd --name rhel-image-10.vhd Percent complete: 100.0%List the storage containers:
To display in the tabular format, enter:
$ az storage container list --output tableTo display in the YAML format, enter:
$ az storage container list --output yaml
Use the URL for the uploaded
VHDfile from the 1st step:$ az storage blob url -c <container_name> -n _<image_name>.vhd _<url_of_vhd_file>_Example:
$ az storage blob url -c azrhelclistcont -n rhel-image-10.vhd "https://azrhelclistact.blob.core.windows.net/azrhelclistcont/rhel-image-10.vhd"Create the Azure custom image:
$ az image create -n _<image_name> -g _<resource_group> -l _<azure_region> --source _<URL> --os-type linux注意The default hypervisor generation of the VM is V1. You can optionally specify a V2 hypervisor generation by including the option
--hyper-v-generation V2. Generation 2 VMs use a UEFI-based boot architecture. For details, see Support for generation 2 VMs on Azure. The command may return the error "Only blobs formatted as VHDs can be imported." This error may mean that the image was not aligned to the nearest 1 MB boundary before it was converted toVHD.Example:
$ az image create -n rhel10 -g azrhelclirsgrp2 -l southcentralus --source https://azrhelclistact.blob.core.windows.net/azrhelclistcont/rhel-image-10.vhd --os-type linux
Next steps
- You can launch and connect to a Azure VM.