Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to: Hyperconverged deployments of Azure Local 2311.2 and later
This article describes how to create virtual machine (VM) images for Azure Local using source images from a local share. You can create VM images by using the Azure portal or Azure CLI. Then, use these VM images to create Azure Local VMs.
Prerequisites
Before you begin, make sure that you complete the following prerequisites.
Make sure to review and complete the prerequisites.
For custom images in a local share on your Azure Local, you'll have the following extra prerequisites:
- You should have a VHD/VHDX uploaded to a local share on your system.
- The VHDX image must be Gen 2 type and secure boot enabled.
- The VHDX image OS must be activated, including but not limited to KMS or AVMA.
- The VHDX image must be prepared using
sysprep /generalize /shutdown /oobe. For more information, see Sysprep command-line options. - The image should reside on a cluster shared volume available to all the machines in the instance. Both the Windows and Linux operating systems are supported.
- If using a client to connect to your Azure Local instance, see Connect to Azure Local via Azure CLI client.
Add VM image from image in local share
You create a VM image starting from an image in a local share of your system. Then, use this image to deploy VMs on your Azure Local.
Follow these steps to create a VM image using the Azure CLI.
Sign in and set subscription
Connect to a machine on your Azure Local.
Sign in. Type:
az login --use-device-codeSet your subscription.
az account set --subscription <Subscription ID>
Set some parameters
Set your subscription, resource group, location, OS type for the image. Replace the parameters in
< >with the appropriate values.$subscription = "<Subscription ID>" $resourceGroup = "<Resource group>" $customLocationID = "<Custom or extended location of your Azure Local instance>" $location = "<Location for your Azure Local>" $imageSourcePath = '"<Path to the source image in local share>"' $imageName = "<VM image name>" $osType = "<OS of source image>" $storagePathID = "/subscriptions/<Subscription ID>/resourceGroups/local-rg/providers/Microsoft.AzureStackHCI/storagecontainers/local-sp"The parameters are described in the following table:
Parameter (CLI flag) Variable name Description subscription$subscription Subscription group for Azure Local that you associate with this image. resource-group$resourceGroup Resource group for Azure Local that you associate with this image. custom-location$customLocationID ARM ID of the custom or extended location of your Azure Local instance. location$location Location for your Azure Local instance. For example, eastus.image-path$imageSourcePath Path to the source gallery image (VHDX only) in local share. For example, C:\OSImages\winos.vhdx. See the prerequisites of the source image.name$imageName Name of the VM image created starting with the image in your local share.
Note: Azure rejects all the names that contain the keyword Windows.os-type$osType Operating system associated with the source image. For example, Windows or Linux. storage-path-id$storagePathID The associated storage path where the VM configuration and the data are saved. Here's a sample output:
PS C:\Users\azcli> $subscription = "<Subscription ID>" PS C:\Users\azcli> $resourceGroup = "mylocalrg" PS C:\Users\azcli> $location = "eastus" PS C:\Users\azcli> $osType = "Windows" PS C:\ClusterStorage\Volume1> $imageName = "mylocal-localimage" PS C:\ClusterStorage\Volume1> $imageSourcePath = "C:\ClusterStorage\Volume1\Windows_K8s_17763.2928.220505-1621_202205101158.vhdx"
Add VM image from image in local share
Select a custom location to deploy your VM image. The custom location should correspond to the custom location for your Azure Local. Get the custom location ID for your Azure Local. Run the following command:
$customLocationID=(az customlocation show --resource-group $resourceGroup --name "<custom location name for system>" --query id -o tsv)Create the VM image starting with a specified image in a local share on your Azure Local.
az stack-hci-vm image create --subscription $subscription --resource-group $resourceGroup --custom-location $customLocationID --location $location --image-path $imageSourcePath --name $imageName --os-type $osType --storage-path-id $storagePathIDA deployment job starts for the VM image.
In this example, the storage path was specified using the --storage-path-id flag. This flag ensures that the workload data (including the VM, VM image, and non-OS data disk) is placed in the specified storage path.
If the flag isn't specified, the workload data is automatically placed in a high availability storage path.
The image deployment takes a few minutes to complete. The time taken to download the image depends on the size of the image in the local share and the network bandwidth available for the download.
Here's a sample output:
PS C:\Users\azcli> $customLocationID=(az customlocation show --resource-group $resourceGroup --name "myhci-cl" --query id -o tsv)
PS C:\Users\azcli> az stack-hci-vm image create --subscription $subscription --resource-group $resourceGroup --custom-location $customLocationID --location $location --image-path $imageSourcePath --name $imageName --os-type $osType --storage-path-id $storagePathID
type="CustomLocation" --location $Location --name $mktplaceImage --os-type $osType --image-path $mktImageSourcePath
Command group 'azurestackhci' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
{
"extendedLocation": {
"name": "/subscriptions/<Subscription ID>/resourceGroups/mylocal-rg/providers/Microsoft.ExtendedLocation/customLocations/mylocal-cl",
"type": "CustomLocation"
},
"id": "/subscriptions/<Subscription ID>/resourceGroups/mylocal-rg/providers/Microsoft.AzureStackHCI/galleryimages/mylocal-localimage",
"location": "eastus",
"name": "mylocal-localimage",
"properties": {
"identifier": null,
"imagePath": null,
"osType": "Windows",
"provisioningState": "Succeeded",
"status": {
"downloadStatus": {},
"progressPercentage": 100,
"provisioningStatus": {
"operationId": "82f58893-b252-43db-97a9-258f6f7831d9*43114797B86E6D2B28C4B52B02302C81C889DABDD9D890F993665E223A5947C3",
"status": "Succeeded"
}
},
"storagepathId": "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/storagecontainers/myhci-storagepath",
"version": {
"name": null,
"properties": {
"storageProfile": {
"osDiskImage": {}
}
}
}
},
"resourceGroup": "myhci-rg",
"systemData": {
"createdAt": "2023-11-02T06:15:10.450908+00:00",
"createdBy": "guspinto@contoso.com",
"createdByType": "User",
"lastModifiedAt": "2023-11-02T06:15:56.689323+00:00",
"lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
"lastModifiedByType": "Application"
},
"tags": null,
"type": "microsoft.azurestackhci/galleryimages"
}