Use Azure Marketplace image to create VM image for your Azure Stack Edge Pro GPU
APPLIES TO: Azure Stack Edge Pro - GPUAzure Stack Edge Pro 2Azure Stack Edge Pro RAzure Stack Edge Mini R
To deploy VMs on your Azure Stack Edge Pro GPU device, you need to create a VM image that you can use to create VMs. This article describes the steps that are required to create a VM image starting from an Azure Marketplace image. You can then use this VM image to deploy VMs on your Azure Stack Edge Pro GPU device.
VM image workflow
The following steps describe the VM image workflow using an Azure Marketplace workflow:
- Connect to the Azure Cloud Shell or a client with Azure CLI installed.
- Search the Azure Marketplace and identify your preferred image.
- Create a new managed disk from the Marketplace image.
- Export a VHD from the managed disk to Azure Storage account.
- Clean up the managed disk.
For more information, go to Deploy a VM on your Azure Stack Edge Pro device using Azure PowerShell.
Prerequisites
Before you can use Azure Marketplace images for Azure Stack Edge, make sure you're connected to Azure in either of the following ways.
Use the Bash environment in Azure Cloud Shell. For more information, see Quickstart for Bash in Azure Cloud Shell.
If you prefer to run CLI reference commands locally, install the Azure CLI. If you're running on Windows or macOS, consider running Azure CLI in a Docker container. For more information, see How to run the Azure CLI in a Docker container.
If you're using a local installation, sign in to the Azure CLI by using the az login command. To finish the authentication process, follow the steps displayed in your terminal. For other sign-in options, see Sign in with the Azure CLI.
When you're prompted, install the Azure CLI extension on first use. For more information about extensions, see Use extensions with the Azure CLI.
Run az version to find the version and dependent libraries that are installed. To upgrade to the latest version, run az upgrade.
Search for Azure Marketplace images
Identify a specific Azure Marketplace image that you wish to use. Azure Marketplace hosts thousands of VM images.
To find some of the most commonly used Marketplace images that match your search criteria, run the following command.
az vm image list --all [--publisher <Publisher>] [--offer <Offer>] [--sku <SKU>]
The last three flags are optional but excluding them returns a long list.
Some example queries are:
#Returns all images of type "Windows Server"
az vm image list --all --publisher "MicrosoftWindowsserver" --offer "WindowsServer"
#Returns all Windows Server 2019 Datacenter images from West US published by Microsoft
az vm image list --all --location "westus" --publisher "MicrosoftWindowsserver" --offer "WindowsServer" --sku "2019-Datacenter"
#Returns all VM images from a publisher
az vm image list --all --publisher "Canonical"
Here's an example output when VM images of a certain publisher, offer, and SKU were queried.
PS /home/user> az vm image list --all --publisher "Canonical" --offer "UbuntuServer" --sku "12.04.4-LTS"
[
{
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "12.04.4-LTS",
"urn": "Canonical:UbuntuServer:12.04.4-LTS:12.04.201402270",
"version": "12.04.201402270"
},
{
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "12.04.4-LTS",
"urn": "Canonical:UbuntuServer:12.04.4-LTS:12.04.201404080",
"version": "12.04.201404080"
},
{
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "12.04.4-LTS",
"urn": "Canonical:UbuntuServer:12.04.4-LTS:12.04.201404280",
"version": "12.04.201404280"
},
{
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "12.04.4-LTS",
"urn": "Canonical:UbuntuServer:12.04.4-LTS:12.04.201405140",
"version": "12.04.201405140"
},
{
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "12.04.4-LTS",
"urn": "Canonical:UbuntuServer:12.04.4-LTS:12.04.201406060",
"version": "12.04.201406060"
},
{
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "12.04.4-LTS",
"urn": "Canonical:UbuntuServer:12.04.4-LTS:12.04.201406190",
"version": "12.04.201406190"
},
{
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "12.04.4-LTS",
"urn": "Canonical:UbuntuServer:12.04.4-LTS:12.04.201407020",
"version": "12.04.201407020"
},
{
"offer": "UbuntuServer",
"publisher": "Canonical",
"sku": "12.04.4-LTS",
"urn": "Canonical:UbuntuServer:12.04.4-LTS:12.04.201407170",
"version": "12.04.201407170"
}
]
PS /home/user>
In this example, we'll select Windows Server 2019 Datacenter Core, version 2019.0.20190410. We'll identify this image by its Universal Resource Number (“URN”).
Commonly used Marketplace images
Below is a list of URNs for some of the most commonly used images. If you just want the latest version of a particular OS, the version number can be replaced with "latest" in the URN. For example, “MicrosoftWindowsServer:WindowsServer:2019-Datacenter:Latest”.
OS | SKU | Version | URN |
---|---|---|---|
Windows Server | 2019 Datacenter | 17763.1879.2104091832 | MicrosoftWindowsServer:WindowsServer:2019-Datacenter:17763.1879.2104091832 |
Windows Server | 2019 Datacenter (30-GB small disk) | 17763.1879.2104091832 | MicrosoftWindowsServer:WindowsServer:2019-Datacenter-smalldisk:17763.1879.2104091832 |
Windows Server | 2019 Datacenter Core | 17763.1879.2104091832 | MicrosoftWindowsServer:WindowsServer:2019-Datacenter-Core:17763.1879.2104091832 |
Windows Server | 2019 Datacenter Core (30-GB small disk) | 17763.1879.2104091832 | MicrosoftWindowsServer:WindowsServer:2019-Datacenter-Core-smalldisk:17763.1879.2104091832 |
Windows Desktop | Windows 10 20H2 Pro | 19042.928.2104091209 | MicrosoftWindowsDesktop:Windows-10:20h2-pro:19042.928.2104091209 |
Ubuntu Server | Canonical Ubuntu Server 18.04 LTS | 18.04.202002180 | Canonical:UbuntuServer:18.04-LTS:18.04.202002180 |
Ubuntu Server | Canonical Ubuntu Server 16.04 LTS | 16.04.202104160 | Canonical:UbuntuServer:16.04-LTS:16.04.202104160 |
Create a new managed disk from the Marketplace image
Create an Azure Managed Disk from your chosen Marketplace image.
Set some parameters.
$urn = <URN of the Marketplace image> #Example: “MicrosoftWindowsServer:WindowsServer:2019-Datacenter:Latest” $diskName = <disk name> #Name for new disk to be created $diskRG = <resource group> #Resource group that contains the new disk
Create the disk and generate a SAS access URL.
az disk create -g $diskRG -n $diskName --image-reference $urn $sas = az disk grant-access --duration-in-seconds 36000 --access-level Read --name $diskName --resource-group $diskRG $diskAccessSAS = ($sas | ConvertFrom-Json)[0].accessSas
Here's an example output:
PS /home/user> $urn = “MicrosoftWindowsServer:WindowsServer:2019-Datacenter:Latest”
PS /home/user> $diskName = "newmanageddisk1"
PS /home/user> $diskRG = "newrgmd1"
PS /home/user> az disk create -g $diskRG -n $diskName --image-reference $urn
{
"burstingEnabled": null,
"creationData": {
"createOption": "FromImage",
"galleryImageReference": null,
"imageReference": {
"id": "/Subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/Providers/Microsoft.Compute/Locations/eastus/Publishers/MicrosoftWindowsServer/ArtifactTypes/VMImage/Offers/WindowsServer/Skus/2019-Datacenter/Versions/17763.1935.2105080716",
"lun": null
},
"logicalSectorSize": null,
"sourceResourceId": null,
"sourceUniqueId": null,
"sourceUri": null,
"storageAccountId": null,
"uploadSizeBytes": null
},
"diskAccessId": null,
"diskIopsReadOnly": null,
"diskIopsReadWrite": 500,
"diskMBpsReadOnly": null,
"diskMBpsReadWrite": 100,
"diskSizeBytes": 136367308800,
"diskSizeGb": 127,
"diskState": "Unattached",
"encryption": {
"diskEncryptionSetId": null,
"type": "EncryptionAtRestWithPlatformKey"
},
"encryptionSettingsCollection": null,
"extendedLocation": null,
"hyperVGeneration": "V1",
"id": "/subscriptions/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/resourceGroups/newrgmd1/providers/Microsoft.Compute/disks/NewManagedDisk1",
"location": "eastus",
"managedBy": null,
"managedByExtended": null,
"maxShares": null,
"name": "NewManagedDisk1",
"networkAccessPolicy": "AllowAll",
"osType": "Windows",
"propertyUpdatesInProgress": null,
"provisioningState": "Succeeded",
"purchasePlan": null,
"resourceGroup": "newrgmd1",
"securityProfile": null,
"shareInfo": null,
"sku": {
"name": "Premium_LRS",
"tier": "Premium"
},
"supportsHibernation": null,
"tags": {},
"tier": "P10",
"timeCreated": "2021-06-08T00:39:34.205982+00:00",
"type": "Microsoft.Compute/disks",
"uniqueId": "1a649ad4-3b95-471e-89ef-1d2ed1f51525",
"zones": null
}
PS /home/user> $sas = az disk grant-access --duration-in-seconds 36000 --access-level Read --name $diskName --resource-group $diskRG
PS /home/user> $diskAccessSAS = ($sas | ConvertFrom-Json)[0].accessSas
PS /home/user>
Export a VHD from the managed disk to Azure Storage
This step exports a VHD from the managed disk to your preferred Azure blob storage account. This VHD can then be used to create VM images on Azure Stack Edge.
Set the destination storage account where the VHD is copied.
$storageAccountName = <destination storage account name> $containerName = <destination container name> $destBlobName = <blobname.vhd> #Blob that will be created, including .vhd extension $storageAccountKey = <storage account key>
Copy the VHD to the destination storage account.
$destContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey Start-AzureStorageBlobCopy -AbsoluteUri $diskAccessSAS -DestContainer $containerName -DestContext $destContext -DestBlob $destBlobName
The VHD copy takes several minutes to complete. Ensure the copy completes before proceeding by running the following command. The status field shows “Success” when complete.
Get-AzureStorageBlobCopyState –Container $containerName –Context $destContext -Blob $destBlobName
Here's an example output:
PS /home/user> $storageAccountName = "edgeazurevmeus"
PS /home/user> $containerName = "azurevmmp"
PS /home/user> $destBlobName = "newblobmp.vhd"
PS /home/user> $storageAccountKey = "n9sCytWLdTBz0F4Sco9SkPGWp6BJBtf7BJBk79msf1PfxJGQdqSfu6TboZWZ10xyZdc4y+Att08cC9B79jB0YA=="
PS /home/user> $destContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
PS /home/user> Start-AzureStorageBlobCopy -AbsoluteUri $diskAccessSAS -DestContainer $containerName -DestContext $destContext -DestBlob $destBlobName
AccountName: edgeazurevmeus, ContainerName: azurevmmp
Name BlobType Length ContentType LastModified AccessTier SnapshotTime IsDeleted VersionId
---- -------- ------ ----------- ------------ ---------- ------------ --------- ---------
newblobmp.vhd PageBlob -1 2021-06-08 00:50:10Z False
PS /home/user> Get-AzureStorageBlobCopyState –Container $containerName –Context $destContext -Blob $destBlobName
CopyId : 24a1e3f5-886a-490d-9dd7-562bb4acff58
CompletionTime :
Status : Pending
Source : https://md-lfn221fppr2c.blob.core.windows.net/d4tb2hp5ff2q/abcd?sv=2018-03-28&sr=b&si=4f588db1-9aac-44d9-9607-35497cc08a7f
BytesCopied : 696254464
TotalBytes : 136367309312
StatusDescription :
DestinationSnapshotTime :
PS /home/user> Get-AzureStorageBlobCopyState –Container $containerName –Context $destContext -Blob $destBlobName
CopyId : 24a1e3f5-886a-490d-9dd7-562bb4acff58
CompletionTime : 6/8/2021 12:57:26 AM +00:00
Status : Success
Source : https://md-lfn221fppr2c.blob.core.windows.net/d4tb2hp5ff2q/abcd?sv=2018-03-28&sr=b&si=4f588db1-9aac-44d9-9607-35497cc08a7f
BytesCopied : 136367309312
TotalBytes : 136367309312
StatusDescription :
DestinationSnapshotTime :
Clean up the managed disk
To delete the managed disk you created, follow these steps:
az disk revoke-access --name $diskName --resource-group $diskRG
az disk delete --name $diskName --resource-group $diskRG --yes
The deletion takes a couple minutes to complete.