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 Azure Local virtual machines (VMs) enabled by Azure Arc using source images from the Azure Storage account. You can create VM images by using the Azure portal or Azure CLI and 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 Azure Storage account, you have the following extra prerequisites:
- You should have a VHD loaded in your Azure Storage account. See how to Upload a VHD image in your Azure Storage account.
- Make sure that you're uploading your VHD or VHDX as a page blob image into the Storage account. Only page blob images are supported to create VM images via the Storage account.
- If using a VHDX:
- The VHDX image must be Gen 2 type and secure boot enabled.
- The VHDX image must be prepared using
sysprep /generalize /shutdown /oobe. For more information, see Sysprep command-line options. This is true for both Windows and Linux VM images.
If you're using a client to connect to your Azure Local instance, see Connect to Azure Local via Azure CLI client.
Make sure that you have the Storage Blob Data Contributor role on the storage account that you use for the image. For more information, see Assign an Azure role for access to blob data.
Add VM image from Azure Storage account
You create a VM image starting from an image in Azure Storage account and 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, image path, and OS type for the image. Replace the parameters in
< >with your values.
$subscription = "<Subscription ID>"
$resource_group = "<Resource group>"
$location = "<Location for your Azure Local>"
$osType = "<OS of source image>"
$imageName = "<VM image name>"
$imageSourcePath = '"<Blob SAS URL path to the source image in the storage account>"'
Note
For $imageSourcePath, you must escape the string with double quotes, then enclose it with single quotes as follows: '""'.
The parameters are described in the following table:
| Parameter | Description |
|---|---|
subscription |
Subscription for Azure Local that you associate with the storage account VM image. |
resource_group |
Resource group for Azure Local that you associate with the storage account VM image. |
location |
Location for your Azure Local instance. For example, eastus. |
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. |
imageSourcePath |
Blob SAS URL path to the source image in the storage account. For instructions, see Generating SAS tokens. Note: Escape the path string with double quotes, then enclose it with single quotes as follows: '""'. |
os-type |
Operating system associated with the source image. For example, Windows or Linux. |
Here's a sample output:
PS C:\Users\azcli> $subscription = "<Subscription ID>"
PS C:\Users\azcli> $resource_group = "mylocal-rg"
PS C:\Users\azcli> $location = "eastus"
PS C:\Users\azcli> $osType = "Windows"
PS C:\Users\azcli> $imageName = "mylocal-storacctimage"
PS C:\Users\azcli> $imageSourcePath = '"https://vmimagevhdsa1.blob.core.windows.net/vhdcontainer/Windows_InsiderPreview_ServerStandard_en-us_VHDX_25131.vhdx?sp=r"&"st=2022-08-05T18:41:41Z"&"se=2022-08-06T02:41:41Z"&"spr=https"&"sv=2021-06-08"&"sr=b"&"sig=X7A98cQm%2FmNRaHmTbs9b4OWVv%2F9Q%2FJkWDBHVPyAc8jo%3D"'
Add VM image from image in Azure Storage account
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 $resource_group --name "<custom location name for your Azure Local>" --query id -o tsv)Create the VM image starting with a specified image from Azure Storage account. Make sure to specify the offer, publisher, SKU, and version for the image.
az stack-hci-vm image create --subscription $subscription --resource-group $resource_Group --custom-location $customLocationID --location $location --name $imageName --os-type $osType --image-path $imageSourcePath --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 Azure Storage account and the network bandwidth available for the download.
Here's a sample output:
PS C:\Users\azcli> az stack-hci-vm image create --subscription $subscription --resource-group $resource_Group --custom-location $customLocationID --location $location --name $imageName --os-type $osType --image-path $imageSourcePath --storage-path-id $storagepathid
{
"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-storacctimage",
"location": "eastus",
"name": "windos",
"properties": {
"identifier": null,
"imagePath": null,
"osType": "Windows",
"provisioningState": "Succeeded",
"status": {
"downloadStatus": {
"downloadSizeInMB": 7876
},
"progressPercentage": 100,
"provisioningStatus": {
"operationId": "cdc9c9a8-03a1-4fb6-8738-7a8550c87fd1*31CE1EA001C4B3E38EE29B78ED1FD47CCCECF78B4CEA9E9A85C0BAEA5F6D80CA",
"status": "Succeeded"
}
},
"storagepathId": "/subscriptions/<Subscription ID>/resourceGroups/mylocal-rg/providers/Microsoft.AzureStackHCI/storagecontainers/mylocal-storagepath",
"version": null
},
"resourceGroup": "mylocal-rg",
"systemData": {
"createdAt": "2023-11-03T20:17:10.971662+00:00",
"createdBy": "guspinto@contoso.com",
"createdByType": "User",
"lastModifiedAt": "2023-11-03T21:08:01.190475+00:00",
"lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
"lastModifiedByType": "Application"
},
"tags": null,
"type": "microsoft.azurestackhci/galleryimages"
}