在 Azure 中创建准备好的映像计算机目录
请使用以下方法创建准备好的映像并使用准备好的映像创建 MCS 计算机目录:
使用准备好的映像创建 MCS 计算机目录的关键步骤如下:
- 创建映像定义和初始映像版本。
- 使用映像版本作为准备好的映像来创建目录
使用 Web Studio
创建映像定义和初始映像版本
要创建映像定义和初始映像版本,请执行以下操作:
- 从 Web Studio 中,转到映像节点,然后单击创建映像定义。 单击简介页面上的下一步。
- 在映像定义页面上,指定映像定义的操作系统类型和会话类型。
- 选择一个现有的资源组或创建一个新的资源组来保存映像资源。 要启用映像共享,请选择将映像版本放置在 Azure Compute Gallery 中,然后选择创建新库或使用现有库来保存其映像版本。
-
在映像页面上,选择资源(仅列出适用于设置的连接的资源)和主映像以用作创建映像版本的模板。 可以选中使用计算机配置文件复选框并选择一个计算机配置文件。
注意:
在选择映像之前,请验证主映像是否安装了 VDA 2311 或更高版本,并且在 VDA 上安装了 MCSIO 驱动程序。
-
在存储和许可类型页面上,选择要在映像准备过程中使用的存储和许可证类型。
注意:
如果在映像页面上选择计算机配置文件,则会根据配置文件设置预先选择计算机配置文件的许可证类型。
- 在计算机规格页面上,选择计算机大小。 如果在映像页面上选择计算机配置文件,则默认情况下会选择计算机配置文件的计算机大小。
- 在 NIC 页面上,为准备映像选择或添加 NIC。 对于每个 NIC,请选择一个关联的虚拟网络。
- 在磁盘设置页面上,选择客户管理的加密密钥 (CMEK)。 如果计算机配置文件没有 CMEK 但主映像有,它将从主映像中预先选择 CMEK。
- 在版本说明页面上,输入创建的初始映像版本的说明。
- 在摘要页面上,查看映像定义和创建的初始映像版本的详细信息。 输入映像定义的名称和说明。 单击完成。
创建映像版本
映像版本允许管理特定映像的不同迭代或更新。 此功能使您可以维护映像的多个版本以用于不同的目的。
要基于初始映像版本创建映像版本,请执行以下操作:
注意:
所有映像版本的托管单元必须相同。
- 转到映像节点,选择一个映像版本或映像定义,然后单击创建映像版本。
- 在“映像定义”页面上,可以更改托管单元,并重新选择该映像版本的主映像和计算机配置文件。
- 如果您希望映像版本的配置与配置的初始映像版本不同,请配置创建映像版本对话框的存储和许可证类型、计算机规格、NIC 和磁盘设置页面上的设置。
- 为映像版本添加说明。 单击完成。

注意:
如果由于任何原因导致映像版本的创建失败,底部的故障排除选项卡提供了重试选项。
共享准备好的映像
要在 Azure 的不同主机单元之间共享准备好的映像,请按照以下步骤进行操作:
- 右键单击某个映像版本并选择管理映像共享。 列出选定连接下的所有主机单元。 已禁止对从中创建映像版本的资源执行任何操作。
- 选择您想要与其共享映像的主机单元,然后单击保存。 共享状态列显示“正在进行中”。
- 单击资源选项卡以获取有关共享状态的更多详细信息。
注意:
当映像版本共享的状态为正在进行时,用于删除映像版本或管理映像共享的选项将禁用。
从“映像”节点创建计算机目录
通过映像节点中的创建目录选项可使用映像版本创建目录。
或者,您可以在计算机目录节点中创建目录时选择版本,链接到目录创建工作流程中的准备好的映像选项。 请参阅从“计算机目录”节点创建计算机目录
要从映像节点创建 MCS 计算机目录,请执行以下操作:
- 选择映像版本,然后单击创建目录。 单击简介页面上的下一步。
- 在 Desktop Experience(桌面体验)页面上,选择所需的桌面体验。
- 从映像页面到磁盘设置页面,根据所选映像版本预先选择设置。
- 在资源组页面上,可以选择创建新资源组或者使用现有资源组来放置此目录的资源。
- 完成以下页面上的设置。
- 在摘要页面上,查看计算机目录的详细信息。 输入计算机目录的名称和说明。 单击完成。
- 转到计算机目录节点以查看创建的计算机目录。
从“计算机目录”节点创建计算机目录
要从计算机目录节点创建 MCS 计算机目录,请执行以下操作:
- 在左侧导航窗格中单击 Machine Catalogs(计算机目录)。
- 单击 Create Machine Catalog(创建计算机目录)。 此时将出现计算机目录设置页面。 在简介、计算机类型和计算机管理页面中单击下一步。
- 在计算机管理页面上,选择以下设置:
- 选择进行电源管理的计算机(例如,虚拟机或刀片式 PC)。
- 选择 Citrix Provisioning 技术。 然后,选择 Citrix Machine Creation Services™。
- 在资源字段中,列出了属于不同区域的资源。 选择任意 Azure 网络资源,然后单击下一步。
- 在映像页面上:对于“主映像”类型,请按照以下步骤进行操作:
- 选择“主映像”。
- 在“主映像”下,选择一个映像。 该边栏选项卡列出了与资源属于同一区域的所有映像。
- 单击完成。
- 对于准备好的映像类型,请选择准备好的映像。
- 在准备好的映像下,选择映像定义的映像版本。
- 单击映像版本名称。 要查看有关所选映像版本的更多详细信息,请单击带有下划线的版本号。
- 如果选定的映像版本配置了计算机配置文件,请选择计算机配置文件。 如果选定的映像版本未配置计算机配置文件,则无法选择使用计算机配置文件。
- 在以下页面上配置设置。
- 在磁盘设置页面上,如果选定的准备好的映像使用磁盘加密集,则无法删除该加密集,但您可以将密钥更改为另一个加密密钥。
- 在资源组页面上,可以选择创建新资源组或者使用现有资源组来放置此目录的资源。
- 完成以下页面上的设置。
- 在摘要页面上,查看计算机目录的详细信息。 输入计算机目录的名称和说明。 单击完成。
使用 PowerShell
创建准备好的映像
用于创建准备好的映像版本规范的详细 PowerShell 命令如下所示:
-
使用
Test-ProvImageDefinitionNameAvailable 命令检查可用的映像定义名称。 例如,Test-ProvImageDefinitionNameAvailable -ImageDefinitionName <string[]> <!--NeedCopy--> -
使用
New-ProvImageDefinition命令创建映像定义。 例如,New-ProvImageDefinition -ImageDefinitionName image1 -OsType Windows -VdaSessionSupport MultiSession <!--NeedCopy--> -
使用
Add-ProvImageDefinitionConnection命令在指定的托管连接中为映像定义创建新配置。Add-ProvImageDefinitionConnection的CustomProperties可以包含以下内容。 如果不使用这些参数,则将使用默认值。-
ResourceGroups:具有基础磁盘的资源组。 -
UseSharedImageGallery:指示基础磁盘的类型。 使用true进行 ACG(映像共享),使用false创建快照。 -
ImageGallery:基础磁盘为 ACG 映像版本时的库名称。
例如,
-
对于快照和客户提供的资源组:
$CustomerOwnRsourceGroupProperties = @" <CustomProperties xmlns="http:// schemas.citrix.com/2014/xd/machinecreation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Property xsi:type="StringProperty" Name="ResourceGroups" Value="yangj_image" /> </CustomProperties> "@ <!--NeedCopy--> -
对于 ACG 和客户提供的资源组和映像库:
$CustomerOwnAllProperties = @" <CustomProperties xmlns="http://schemas.citrix.com/2014/xd/machinecreation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Property xsi:type="StringProperty" Name="UseSharedImageGallery" Value="true" /> <Property xsi:type="StringProperty" Name="ResourceGroups" Value="rg" /> <Property xsi:type="StringProperty" Name="ImageGallery" Value="gallery" /> </CustomProperties> "@ <!--NeedCopy--> -
In case of ACG and customer provided resource group only:
$CustomerOwnResourceGroupProperties = @" <CustomProperties xmlns="http://schemas.citrix.com/2014/xd/machinecreation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Property xsi:type="StringProperty" Name="UseSharedImageGallery" Value="true" /> <Property xsi:type="StringProperty" Name="ResourceGroups" Value="rg" /> </CustomProperties> "@ <!--NeedCopy--> -
In case of ACG and resource group and image gallery managed by Citrix:
$CustomerOwnResourceGroupNothingProperties = @" <CustomProperties xmlns="http://schemas.citrix.com/2014/xd/machinecreation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Property xsi:type="StringProperty" Name="UseSharedImageGallery" Value="true" /> </CustomProperties> "@ <!--NeedCopy-->
Add-ProvImageDefinitionConnection -ImageDefinitionName image1 -HypervisorConnectionName Azure28 [-CustomProperties $CustomProperties] <!--NeedCopy--> -
-
Create an image version using the
New-ProvImageVersioncommand. For example,```
New-ProvImageVersion -ImageDefinitionName image1 -Description “version 1”
1. Add a master image version spec to the image version using the `Add-ProvImageVersionSpec` command. For example,
```
Add-ProvImageVersionSpec -ImageDefinitionName image1 -ImageVersionNumber 1 -HostingUnitName azure -MasterImagePath "XDHyp:\HostingUnits\azure\image.folder\azureresourcegroup.resourcegroup\win2022-snapshot.snapshot"
<!--NeedCopy-->
> **Note:**
>
> You can add only one master image version spec to one image version for a hosting unit.
- Create a prepared image version spec from the master image version spec using the
New-ProvImageVersionSpeccommand. For example,
```
New-ProvImageVersionSpec -SourceImageVersionSpecUid c6e7384c-b2f8-46d6-9519-29a2c57ed3cb -NetworkMapping @{“0”=”XDHyp:\HostingUnits\azure\virtualprivatecloud.folder\azureresourcegroup.resourcegroup\azure-vnet-eastus.virtualprivatecloud\dev.network”} -ServiceOffering”XDHyp:\HostingUnits\azure\serviceoffering.folder\Standard_B2ms.serviceoffering” -CustomProperties “<CustomProperties xmlns="http://schemas.citrix.com/2014/xd/machinecreation” xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance”></CustomProperties>” -RunAsynchronously
1. You can also share prepared image version spec with another hosting unit within the same hosting connection using the `Add-ProvImageVersionSpecHostingUnit` command. For example,
```
Add-ProvImageVersionSpecHostingUnit -ImageVersionSpecUid xxxxxxx -HostingUnitName AzureWest
<!--NeedCopy-->
> **Note:**
>
> One hosting unit and preparation type can have only one prepared instance.
Example of the complete set of Powershell commands to create image definition, image version, and prepared image version spec:
New-ProvImageDefinition -ImageDefinitionName image1 -OsType Windows -VdaSessionSupport MultiSession
$CustomProperties = @" <CustomProperties xmlns="http://schemas.citrix.com/2014/xd/machinecreation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <Property xsi:type="StringProperty" Name="UseSharedImageGallery" Value="true" /> <Property xsi:type="StringProperty" Name="ResourceGroups" Value="rg" /> <Property xsi:type="StringProperty" Name="ImageGallery" Value="gallery" /> </CustomProperties> "@
Add-ProvImageDefinitionConnection -ImageDefinitionName image1 -HypervisorConnectionName Azure28 -CustomProperties $CustomProperties
$imageVersion = New-ProvImageVersion -ImageDefinitionName image1 -Description "version 1"
$SourceImageVersionSpec = Add-ProvImageVersionSpec -ImageVersionUid $imageVersion.ImageVersionUid `-HostingUnitUid $hostingunit.HostingUnitUid` -MasterImagePath "XDHyp:\HostingUnits\azure28\image.folder\abc.resourcegroup\def-snapshot.snapshot"
New-ProvImageVersionSpec -NetworkMapping @{"0" = "XDHyp:\HostingUnits\azure28\virtualprivatecloud.folder\East US.region\virtualprivatecloud.folder\studio-mcs-infrastructure.resourcegroup\studio-mcs-vnet-eastus.virtualprivatecloud\mcs-dev.network" } -CustomProperties "<CustomProperties xmlns=`"http://schemas.citrix.com/2014/xd/machinecreation`" xmlns:xsi=`"http://www.w3.org/2001/XMLSchema-instance`"><Property xsi:type=`"StringProperty`" Name=`"LicenseType`" Value=`"Windows_Server`" /></CustomProperties>" -ServiceOffering "XDHyp:\HostingUnits\azure28\serviceoffering.folder\Standard_B2s.serviceoffering" -SourceImageVersionSpecUid $SourceImageVersionSpec.ImageVersionSpecUid Add-ProvImageVersionSpecHostingUnit -ImageVersionSpecUid xxxxxxx -HostingUnitName AzureWest $PreparedImageVersionSpec = Get-ProvImageVersionSpec -ImageVersionUid $imageVersion.ImageVersionUid | Where SourceImageVersionSpecUid-eq $SourceImageVersionSpec.ImageVersionSpecUid
<!--NeedCopy-->
Note:
- All image version specs in an image definition must belong to the same hosting unit.
- An image version can have only one master image version spec and one prepared image version spec.
- All image version specs must either have a machine profile or none of the image version specs must have a machine profile.
Create a catalog using a prepared image version spec
Create an MCS machine catalog from the prepared image version spec using the New-ProvScheme command. For example,
New-ProvScheme -ProvisioningSchemeName <string> -ImageVersionSpecUid <Guid> -HostingUnitUid <Guid> -IdentityPoolUid <Guid> [-VMCpuCount <int>] [-VMMemoryMB <int>] [-UseWriteBackCache] [-NetworkMapping <Hashtable>] [-CleanOnBoot] [-Scope <string[]>] [-Metadata <Hashtable>] [-ServiceOffering <string>] [-SecurityGroup <string[]>] [-TenancyType <string>] [-MachineProfile <string>] [-CustomProperties <string>] \[-ResetAdministratorPasswords\] \[-UseFullDiskCloneProvisioning\] \[-RunAsynchronously\] \[-PurgeJobOnSuccess\] [-ProvisioningSchemeType <ProvisioningSchemeType>]
<!--NeedCopy-->
Or,
New-ProvScheme -ProvisioningSchemeName <string> -ImageVersionSpecUid <Guid> -HostingUnitName <string> -IdentityPoolName <string> [-VMCpuCount <int>] [-VMMemoryMB <int>] [-UseWriteBackCache] [-NetworkMapping <Hashtable>] [-CleanOnBoot] [-Scope <string[]>] [-Metadata <Hashtable>] [-ServiceOffering <string>] [-SecurityGroup <string[]>] [-TenancyType <string>] [-MachineProfile <string>] [-CustomProperties <string>] \[-ResetAdministratorPasswords\] \[-UseFullDiskCloneProvisioning\] \[-RunAsynchronously\] \[-PurgeJobOnSuccess\] [-ProvisioningSchemeType <ProvisioningSchemeType>]
<!--NeedCopy-->
If you want to use an ACG image version spec, then set UseSharedImageGallery as true. For example,
$provSchemeCustomProperties= @" <CustomProperties xmlns="http://schemas.citrix.com/2014/xd/machinecreation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Property xsi:type="StringProperty" Name="UseSharedImageGallery" Value="true" /> <Property xsi:type="StringProperty" Name="StorageAccountType" Value="StandardSSD_LRS" /> </CustomProperties> "@ New-ProvScheme -ProvisioningSchemeName assignimage -ImageVersionSpecUid $PreparedImageVersionSpec.ImageVersionSpecUid `-HostingUnitUid $hostingunit.HostingUnitUid` -IdentityPoolUid $IdentityPool.IdentityPoolUid `-CleanOnBoot -Scope @() -SecurityGroup @()` -ServiceOffering "XDHyp:\HostingUnits\azure28\serviceoffering.folder\Standard_B2s.serviceoffering" `-NetworkMapping @{"0"="XDHyp:\HostingUnits\azure28\virtualprivatecloud.folder\East US.region\virtualprivatecloud.folder\studio-mcs-infrastructure.resourcegroup\studio-mcs-vnet-eastus.virtualprivatecloud\mcs-dev.network"}` -CustomProperties $provSchemeCustomProperties
<!--NeedCopy-->
Example of the complete set of Powershell commands to create a catalog:
$Catalog = New-BrokerCatalog -AllocationType "Random" -IsRemotePC $False -MinimumFunctionalLevel "L7_20" -Name "azurecatalog" -PersistUserChanges "Discard" -ProvisioningType "MCS" -Scope @() -SessionSupport "MultiSession"
$IdentityPool = New-AcctIdentityPool -AllowUnicode -Domain "azure.local" -IdentityPoolName "azurecatalog" -IdentityType "ActiveDirectory" -NamingScheme "azure##" -NamingSchemeType "Numeric" -Scope @()
$PreparedImageVersionSpec = Get-ProvImageVersionSpec -ImageDefinitionName image1 -ImageVersionNumber 1 -Filter "PreparationType -eq 'Mcs'"
$Task = New-ProvScheme -ProvisioningSchemeName azurecatalog -ImageVersionSpecUid $PreparedImageVersionSpec.ImageVersionSpecUid -HostingUnitName azure -IdentityPoolName azurecatalog -CleanOnBoot -Scope @() -SecurityGroup @() -ServiceOffering "XDHyp:\HostingUnits\azure\serviceoffering.folder\Standard_B2s.serviceoffering" -NetworkMapping @{"0"="XDHyp:\HostingUnits\azure\virtualprivatecloud.folder\azureresourcegroup.resourcegroup\azure-vnet-eastus.virtualprivatecloud\dev.network"} -CustomProperties "<CustomProperties xmlns=`"http://schemas.citrix.com/2014/xd/machinecreation`" xmlns:xsi=`"http://www.w3.org/2001/XMLSchema-instance`"> <Property xsi:type="StringProperty" Name="UseSharedImageGallery" Value="true" /><Property xsi:type=`"StringProperty`" Name=`"StorageAccountType`" Value=`"StandardSSD_LRS`" /></CustomProperties>" -RunAsynchronously
Get-ProvTask -TaskId $Task.TaskId $ProvScheme = Get-ProvScheme -ProvisioningSchemeName azurecatalog
Set-BrokerCatalog -Name $Catalog.Name -ProvisioningSchemeId $ProvScheme.ProvisioningSchemeUid <!--NeedCopy-->