培训
认证
Microsoft Certified: Azure Virtual Desktop Specialty - Certifications
在 Microsoft Azure 上为任何设备计划、交付、管理和监视虚拟桌面体验和远程应用。
适用于:Azure Local 2311.2 及更高版本
本文介绍如何使用Azure 市场中的源映像为 Azure 本地创建虚拟机(VM)映像。 可以使用 Azure 门户 或 Azure CLI 创建 VM 映像,然后使用这些 VM 映像在本地创建 Arc VM。
在开始之前,请确保满足以下先决条件。
请确保查看并完成先决条件。
请确保具有 Azure Connected Machine Resource Manager 角色。 有关详细信息,请参阅分配 Azure 角色。
确保订阅已在 Microsoft.EdgeMarketplace
资源提供商处注册。 有关详细信息,请参阅注册资源提供程序。
如果使用客户端连接到 Azure 本地实例,请参阅 远程连接到系统。
从Azure 市场映像开始创建 VM 映像,然后使用此映像在 Azure 本地实例上部署 VM。
按照以下步骤使用 Azure CLI 创建 VM 映像。
登录。 类型:
az login --use-device-code
设置订阅。
az account set --subscription <Subscription ID>
为映像的订阅、资源组、位置和 OS 类型设置参数。 请将 < >
中的参数替换为适当的值。
$subscription = "<Subscription ID>"
$resource_group = "<Resource group>"
$mktplaceImage = "<Marketplace image name>"
$customLocationName = "<Custom location name>"
$customLocationID = (az customlocation show --resource-group $resource_group --name "<custom_location_name_for_Azure_Local>" --query id -o tsv)
$location = "<Location for your Azure Local>"
$osType = "<OS of source image>"
下表介绍了这些参数:
参数 | 说明 |
---|---|
subscription |
与 Azure Local 相关联的订阅。 |
resource-group |
与此映像相关联的 Azure Local 的资源组。 |
name |
Azure Local 的市场映像的名称。 |
customLocation |
Azure Local 自定义位置的资源 ID。 |
location |
你的 Azure Local 的位置。 例如,它可以是 eastus 。 |
os-type |
与源映像关联的操作系统。 这可以是 Windows 或 Linux。 |
下面是示例输出:
PS C:\Users\azcli> $subscription = "<Subscription ID>"
PS C:\Users\azcli> $resource_group = "mylocal-rg"
PS C:\Users\azcli> $mktplaceImage= "mylocal-marketplaceimage"
PS C:\Users\azcli> $customLocationName = "mylocal-cl"
PS C:\Users\azcli> $customerLocationID /subscriptions$subscription/resourcegroups/$resource_group/providers/microsoft.extendedlocation/customlocations/$customLocationName
PS C:\Users\azcli> $location = "eastus"
PS C:\Users\azcli> $ostype = "Windows"
设置用于指定要创建的预期 VM 映像的其他参数。 需要为市场映像提供报价、发布商、SKU 和版本。 将参数 <> 替换为相应的值:
$publisher = "<Publisher name>"
$offer = "<OS offer>"
$sku = "<Image SKU>"
使用下表查找可用的市场图片及其属性值。
名称 | 出版商 | 产品 | SKU |
---|---|---|---|
Windows 11 企业版多会话 + Microsoft 365 | 微软Windows桌面 | office-365 | win11-23h2-avd-m365 win11-24h2-avd-m365 |
Windows 10 企业版多会话 + Microsoft 365 | 微软Windows桌面 | office-365 | win10-21h2-avd-m365 |
Windows 11 专业版 | 微软Windows桌面 | windows-11 | win11-23h2-pro |
Windows 11 企业版 | 微软Windows桌面 | windows-11 | win11-22h2-ent win11-23h2-ent win11-24h2-ent |
Windows 11 企业版多会话 | 微软Windows桌面 | windows-11 | win11-22h2-avd win11-23h2-avd win11-24h2-avd |
Windows 10 专业版 | 微软 Windows 桌面 | windows-10 | win10-22h2-pro-g2 |
Windows 10 企业版 | 微软 Windows 桌面 | windows-10 | win10-22h2-ent-g2 |
Windows 10 企业版多会话 | 微软Windows桌面 | windows-10 | win10-22h2-avd |
Windows Server 2025 Datacenter:Azure Edition | microsoftwindowsserver | windowsserver | 2025-datacenter-azure-edition-smalldisk 2025-datacenter-azure-edition-core 2025-datacenter-azure-edition |
Windows Server 2022 Datacenter:Azure Edition | microsoftwindowsserver | windowsserver | 2022-datacenter-azure-edition-hotpatch 2022-datacenter-azure-edition-core 2022-datacenter-azure-edition |
Windows Server 2019 | microsoftwindowsserver | windowsserver | 2019-datacenter-gensecond 2019-datacenter-core-g2 |
Windows Server 2022 上的 SQL Server 2022 Enterprise | microsoftsqlserver | sql2022-ws2022 | enterprise-gen2 standard-gen2 |
如果想要创建 Windows Server 2019 Datacenter 映像,则具有以下参数:
$publisher = "microsoftwindowsserver"
$offer = "windowsserver"
$sku = "2019-datacenter-gensecond"
创建 VM 镜像,从指定的市场镜像开始。
az stack-hci-vm image create --resource-group $resource_group --custom-location $customLocationID --name $mktplaceImage --os-type $ostype --offer $offer --publisher $publisher --sku $sku
下面是示例输出:
PS C:\Users\azcli> az stack-hci-vm image create --custom-location $cl --name $mktplaceImage --os-type $ostype --resource-group $rg --publisher $publisher --offer $offer --sku $sku
{
"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/marketplacegalleryimages/myhci-marketplaceimage",
\
"location": "eastus",
"name": "myhci-marketplaceimage",
"properties": {
"cloudInitDataSource": null,
"containerId": null,
"hyperVGeneration": null,
"identifier": {
"offer": "windowsserver",
"publisher": "microsoftwindowsserver",
"sku": "2019-datacenter-gensecond"
},
"osType": "Windows",
"provisioningState": "Succeeded",
"status": {
"downloadStatus": {
"downloadSizeInMb": 10832
},
"errorCode": "",
"errorMessage": "",
"progressPercentage": 100,
"provisioningStatus": {
"operationId": "13efc468-7473-429f-911b-858c1e6fc1d5*B11A62EE76B08EF194F8293CDD40F7BC71BFB93255D5A99DD11B4167690752D9",
"status": "Succeeded"
}
},
"version": {
"name": "17763.6293.240905",
"properties": {
"storageProfile": {
"osDiskImage": {
"sizeInMb": 130050
}
}
}
}
},
"resourceGroup": "mylocal-rg",
"systemData": {
"createdAt": "2024-09-23T18:53:13.734389+00:00",
"createdBy": "guspinto@contoso.com",
"createdByType": "User",
"lastModifiedAt": "2024-09-23T19:06:07.532276+00:00",
"lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
"lastModifiedByType": "Application"
},
"tags": null,
"type": "microsoft.azurestackhci/marketplacegalleryimages"
}
有关此 CLI 命令的详细信息,请参阅 az stack-hci-vm 映像。
需要查看 VM 映像列表才能选择要管理的映像。
按照以下步骤使用 Azure CLI 列出 VM 映像。
以管理员身份运行 PowerShell。
设置一些参数。
$subscription = "<Subscription ID associated with your Azure Local>"
$resource_group = "<Resource group name for your Azure Local>"
列出与 Azure 本地关联的所有 VM 映像。 运行下面的命令:
az stack-hci-vm image list --subscription $subscription --resource-group $resource_group
根据所使用的命令,会列出与 Azure Local 关联的相应映像集。
这些映像包括:
下面是示例输出。
PS C:\Users\azcli> az stack-hci-vm image list --subscription "<Subscription ID>" --resource-group "myhci-rg"
Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
[
{
"extendedLocation": {
"name": "/subscriptions/<Subscription ID>/resourcegroups/myhci-rg/providers/microsoft.extendedlocation/customlocations/myhci-cl",
"type": "CustomLocation"
},
"id": "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/microsoft.azurestackhci/marketplacegalleryimages/w
inServer2022Az-01",
"location": "eastus",
"name": "winServer2022Az-01",
"properties": {
"hyperVGeneration": "V2",
"identifier": {
"offer": "windowsserver",
"publisher": "microsoftwindowsserver",
"sku": "2022-datacenter-azure-edition-core"
},
"imagePath": null,
"osType": "Windows",
"provisioningState": "Succeeded",
"status": {
"downloadStatus": {
"downloadSizeInMB": 6710
},
"progressPercentage": 100,
"provisioningStatus": {
"operationId": "19742d69-4a00-4086-8f17-4dc1f7ee6681*E1E9889F0D1840B93150BD74D428EAE483CB67B0904F9A198C161AD471F670ED",
"status": "Succeeded"
}
},
"storagepathId": null,
"version": {
"name": "20348.2031.231006",
"properties": {
"storageProfile": {
"osDiskImage": {
"sizeInMB": 130050
}
}
}
}
},
"resourceGroup": "mylocal-rg",
"systemData": {
"createdAt": "2023-10-30T21:44:53.020512+00:00",
"createdBy": "guspinto@contoso.com",
"createdByType": "User",
"lastModifiedAt": "2023-10-30T22:08:25.495995+00:00",
"lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
"lastModifiedByType": "Application"
},
"tags": {},
"type": "microsoft.azurestackhci/marketplacegalleryimages"
}
]
PS C:\Users\azcli>
有关此 CLI 命令的详细信息,请参阅 az stack-hci-vm image list。
在使用该映像创建 VM 之前,可能需要先查看 VM 映像的属性。 按照以下步骤查看映像属性:
按照以下步骤使用 Azure CLI 查看映像的属性:
以管理员身份运行 PowerShell。
设置以下参数。
$subscription = "<Subscription ID>"
$resource_group = "<Azure Local resource group>"
$mktplaceImage = "<Marketplace image name>"
可以通过两种不同的方式查看映像属性:指定 ID,或指定名称和资源组。 指定市场映像 ID 时,请执行以下步骤:
设置以下参数。
$mktplaceImageID = "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/galleryimages/mylocal-marketplaceimage"
运行以下命令以查看属性。
az stack-hci-vm image show --ids $mktplaceImageID
下面是此命令的示例输出:
PS C:\Users\azcli> az stack-hci-vm image show --ids $mktplaceImageID
Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
{
"extendedLocation": {
"name": "/subscriptions/<Subscription ID>/resourcegroups/myhci-rg/providers/microsoft.extendedlocation/customlocations/mylocal-cl",
"type": "CustomLocation"
},
"id": "/subscriptions/<Subscription ID>/resourceGroups/myhci-rg/providers/Microsoft.AzureStackHCI/galleryimages/mylocal-marketplaceimage",
"location": "eastus",
"name": "mylocal-marketplaceimage",
"properties": {
"containerName": null,
"hyperVGeneration": null,
"identifier": null,
"imagePath": null,
"osType": "Windows",
"provisioningState": "Succeeded",
"status": null,
"version": null
},
"resourceGroup": "mylocal-rg",
"systemData": {
"createdAt": "2022-08-05T20:52:38.579764+00:00",
"createdBy": "guspinto@microsoft.com",
"createdByType": "User",
"lastModifiedAt": "2022-08-05T20:52:38.579764+00:00",
"lastModifiedBy": "guspinto@microsoft.com",
"lastModifiedByType": "User"
},
"tags": null,
"type": "microsoft.azurestackhci/galleryimages"
}
PS C:\Users\azcli>
重要
由于执行其他验证,最新的更新可能需要一些时间才能反映在您的虚拟机镜像上。
Azure 市场中提供了新的更新映像时,Azure 本地上的 VM 映像会过时,应更新。 更新操作不是映像的就地更新。 相反,可以查看已更新映像可用于哪些 VM 映像,并选择要更新的映像。 更新后,创建 VM 映像操作将使用新的已更新映像。
若要更新 VM 映像,请在 Azure 门户中使用以下步骤。
要查看更新是否可用,请从列表视图中选择 VM 映像。
在“概览”边栏选项卡中,会看到横幅,显示可供下载的新 VM 映像(如果有)。 要更新到新映像,请选择箭头图标。
查看映像详细信息,然后选择“查看并创建”。 默认情况下,新映像使用与前一个映像相同的资源组和实例详细信息。
新图像的名称将根据上一个图像的名称递增。 例如,名为 winServer2022-01 的现有映像将具有名为 winServer2022-02 的更新映像。
要完成操作,请选择“创建”。
创建新虚拟机映像后,使用新映像创建虚拟机,并验证虚拟机是否正常工作。 验证后,可以删除旧 VM 映像。
如果下载因某种原因失败,或者不再需要映像,您可能需要删除 VM 映像。 按照以下步骤删除 VM 映像。
以管理员身份运行 PowerShell。
设置以下参数:
$subscription = "<Subscription ID>"
$resource_group = "<Azure Local resource group>"
$mktplaceImage = "<Markeplace image name>"
删除现有的 VM 映像。 运行下面的命令:
az stack-hci-vm image delete --subscription $subscription --resource-group $resource_group --name $mktplaceImage --yes
可以通过两种方式删除映像:
删除某个映像后,可以检查该映像是否已删除。 下面是通过指定名称和资源组删除映像后的示例输出。
PS C:\Users\azcli> $subscription = "<Subscription ID>"
PS C:\Users\azcli> $resource_group = "mylocal-rg"
PS C:\Users\azcli> $mktplaceImage = "mymylocal-marketplaceimage"
PS C:\Users\azcli> az stack-hci-vm image delete --name $mktplaceImage --resource-group $resource_group
Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
Are you sure you want to perform this operation? (y/n): y
PS C:\Users\azcli> az stack-hci-vm image show --name $mktplaceImage --resource-group $resource_group
Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
ResourceNotFound: The Resource 'Microsoft.AzureStackHCI/marketplacegalleryimages/myhci-marketplaceimage' under resource group 'mylocal-rg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix
PS C:\Users\azcli>
培训
认证
Microsoft Certified: Azure Virtual Desktop Specialty - Certifications
在 Microsoft Azure 上为任何设备计划、交付、管理和监视虚拟桌面体验和远程应用。