共享映像库概述Shared Image Galleries overview

共享映像库是一种可以帮助你围绕映像构建结构和组织的服务。Shared Image Gallery is a service that helps you build structure and organization around your images. 共享映像库提供:Shared Image Galleries provide:

  • 支持映像全局复制。Global replication of images.

  • 对映像进行版本控制和分组,以便于管理。Versioning and grouping of images for easier management.

  • 高级存储支持 (Premium_LRS)。Premium storage support (Premium_LRS).

  • 使用 RBAC 在订阅之间,甚至在 Active Directory (AD) 租户之间共享。Sharing across subscriptions, and even between Active Directory (AD) tenants, using RBAC.

  • 使用每个区域中的映像副本缩放部署。Scaling your deployments with image replicas in each region.

使用共享映像库,可以将映像共享给组织内的不同用户、服务主体或 AD 组。Using a Shared Image Gallery you can share your images to different users, service principals, or AD groups within your organization. 共享映像可以复制到多个区域,以便更快地扩展部署。Shared images can be replicated to multiple regions, for quicker scaling of your deployments.

映像是完整 VM(包括任何附加的数据磁盘)的副本或者只是 OS 磁盘的副本,具体取决于映像的创建方式。An image is a copy of either a full VM (including any attached data disks) or just the OS disk, depending on how it is created. 从映像创建 VM 时,将使用该映像中的 VHD 副本来为新 VM 创建磁盘。When you create a VM from the image, a copy of the VHDs in the image are used to create the disks for the new VM. 映像保留在存储中,可反复用来创建新的 VM。The image remains in storage and can be used over and over again to create new VMs.

如果你有大量的映像需要维护,并想要使其在整个公司中可用,可将共享映像库用作存储库。If you have a large number of images that you need to maintain, and would like to make them available throughout your company, you can use a Shared Image Gallery as a repository.

共享映像库功能具有多种资源类型:The Shared Image Gallery feature has multiple resource types:

资源Resource 说明Description
映像源Image source 这是可用于在映像库中创建“映像版本”的资源。This is a resource that can be used to create an image version in an image gallery. 映像源可以是现有的 Azure VM(可以是通用或专用的)、托管映像、快照、VHD 或其他映像库中的映像版本。An image source can be an existing Azure VM that is either generalized or specialized, a managed image, a snapshot, a VHD or an image version in another image gallery.
映像库Image gallery 与 Azure 市场一样,映像库 是用于管理和共享映像的存储库,但你可以控制谁有权访问这些映像。Like the Azure Marketplace, an image gallery is a repository for managing and sharing images, but you control who has access.
映像定义Image definition 映像定义在库中创建,携带有关该映像以及在内部使用该映像的要求的信息。Image definitions are created within a gallery and carry information about the image and requirements for using it internally. 这包括了该映像是 Windows 还是 Linux 映像、发行说明以及最低和最高内存要求。This includes whether the image is Windows or Linux, release notes, and minimum and maximum memory requirements. 它是某种映像类型的定义。It is a definition of a type of image.
映像版本Image version 使用库时,将使用 映像版本 来创建 VM。An image version is what you use to create a VM when using a gallery. 可根据环境的需要创建多个映像版本。You can have multiple versions of an image as needed for your environment. 与托管映像一样,在使用 映像版本 创建 VM 时,将使用映像版本来创建 VM 的新磁盘。Like a managed image, when you use an image version to create a VM, the image version is used to create new disks for the VM. 可以多次使用映像版本。Image versions can be used multiple times.


映像定义Image definitions

映像定义是映像版本的逻辑分组。Image definitions are a logical grouping for versions of an image. 映像定义包含的信息涉及创建映像的原因、映像适用的 OS,以及映像的用法。The image definition holds information about why the image was created, what OS it is for, and other information about using the image. 映像定义就像围绕创建特定映像计划所有详细信息。An image definition is like a plan for all of the details around creating a specific image. 不要从映像定义部署 VM,而要从基于该定义创建的映像版本部署 VM。You don't deploy a VM from an image definition, but from the image versions created from the definition.

每个映像定义有三个可以组合使用的参数:发布者、产品/服务和 SKU 。There are three parameters for each image definition that are used in combination - Publisher, Offer and SKU. 这些参数用于查找特定的映像定义。These are used to find a specific image definition. 可以拥有共享一个或两个但不是全部三个值的映像版本。You can have image versions that share one or two, but not all three values. 例如,以下是三个映像定义及其值:For example, here are three image definitions and their values:

映像定义Image Definition 发布者Publisher 产品/服务Offer SKUSku
myImage1myImage1 ContosoContoso 财务Finance 后端Backend
myImage2myImage2 ContosoContoso 财务Finance 前端Frontend
myImage3myImage3 测试Testing 财务Finance 前端Frontend

所有这三个映像都有唯一的一组值。All three of these have unique sets of values. 格式类似于当前在 Azure PowerShell 中为 Azure 市场映像指定发布者、套餐和 SKU,以获取最新市场映像版本的方式。The format is similar to how you can currently specify publisher, offer, and SKU for Azure Marketplace images in Azure PowerShell to get the latest version of a Marketplace image. 每个映像定义需要包含一组唯一的这些值。Each image definition needs to have a unique set of these values.

以下参数确定了它们可包含哪些类型的映像版本:The following parameters determine which types of image versions they can contain:

  • 操作系统状态 - 可将 OS 状态设置为通用化或专用化Operating system state - You can set the OS state to generalized or specialized. 此字段为必需字段。This field is required.
  • 操作系统 - 可以是 Windows 或 Linux。Operating system - can be either Windows or Linux. 此字段为必需字段。This field is required.
  • Hyper-V 代 - 指定映像是从第 1 代还是第 2 代 Hyper-V VHD 创建的。Hyper-V generation - specify whether the image was created from a generation 1 or generation 2 Hyper-V VHD. 默认值是“第 1 代”。Default is generation 1.

下面是可在映像定义上设置的其他参数,以便你可以更轻松地跟踪资源:The following are other parameters that can be set on your image definition so that you can more easily track your resources:

  • 说明 - 使用说明可以更详细地解释该映像定义为何存在。Description - use description to give more detailed information on why the image definition exists. 例如,可为预装了应用程序的前端服务器创建一个映像定义。For example, you might have an image definition for your front-end server that has the application pre-installed.
  • Eula - 可用于指向特定于映像定义的最终用户许可协议。Eula - can be used to point to an end-user license agreement specific to the image definition.
  • 隐私声明和发行说明 - 将发行说明和隐私声明存储在 Azure 存储中,并提供在映像定义中用于访问它们的 URI。Privacy Statement and Release notes - store release notes and privacy statements in Azure storage and provide a URI for accessing them as part of the image definition.
  • 生命周期结束日期 - 将生命周期结束日期附加到映像定义,以便能够使用自动化功能删除旧的映像定义。End-of-life date - attach an end-of-life date to your image definition to be able to use automation to delete old image definitions.
  • 标记 - 可以在创建映像定义时添加标记。Tag - you can add tags when you create your image definition. 有关标记的详细信息,请参阅使用标记来组织资源For more information about tags, see Using tags to organize your resources
  • 最小和最大 vCPU 与内存建议量 - 如果映像附带 vCPU 和内存建议量,则你可以将该信息附加到映像定义。Minimum and maximum vCPU and memory recommendations - if your image has vCPU and memory recommendations, you can attach that information to your image definition.
  • 不允许的磁盘类型 - 可以提供有关 VM 所需存储的信息。Disallowed disk types - you can provide information about the storage needs for your VM. 例如,如果映像不适合标准 HDD 磁盘,请将其添加到禁止列表。For example, if the image isn't suited for standard HDD disks, you add them to the disallow list.
  • 市场映像的购买计划信息 -PurchasePlanPublisher-PurchasePlanName-PurchasePlanProductPurchase plan information for Marketplace images - -PurchasePlanPublisher, -PurchasePlanName, and -PurchasePlanProduct. 若要详细了解购买计划信息,请参阅在 Azure 市场中查找映像在创建映像时提供 Azure 市场购买计划信息For more information about purchase plan information, see Find images in the Azure Marketplace and Supply Azure Marketplace purchase plan information when creating images.

映像版本Image versions

映像版本用于创建 VM。An image version is what you use to create a VM. 可根据环境的需要创建多个映像版本。You can have multiple versions of an image as needed for your environment. 使用映像版本创建 VM 时,将使用该映像版本来创建该 VM 的新磁盘。When you use an image version to create a VM, the image version is used to create new disks for the VM. 可以多次使用映像版本。Image versions can be used multiple times.

映像版本的属性如下所示:The properties of an image version are:

  • 版本号。Version number. 它用作映像版本的名称。This is used as the name of the image version. 它始终采用以下格式:MajorVersion.MinorVersion.Patch。It is always in the format: MajorVersion.MinorVersion.Patch. 如果指定在创建 VM 时使用最新版本,则依次根据版本最高的 MajorVersion、MinorVersion 和 Patch 选择最新映像。When you specify to use latest when creating a VM, the latest image is chosen based on the highest MajorVersion, then MinorVersion, then Patch.
  • 源。Source. 源可以是 VM、托管磁盘、快照、托管映像,也可以是其他映像版本。The source can be a VM, managed disk, snapshot, managed image, or another image version.
  • 最新版本中不包含它。Exclude from latest. 可将某个版本设为不用作最新映像版本。You can keep a version from being used as the latest image version.
  • 生命周期结束日期。End of life date. 在此之后无法从此映像创建 VM 的日期。Date after which VMs can't be created from this image.

通用化和专用映像Generalized and specialized images

共享映像库支持两种操作系统状态。There are two operating system states supported by Shared Image Gallery. 通常,映像要求在创建映像之前,用于创建映像的 VM 已通用化。Typically images require that the VM used to create the image has been generalized before taking the image. 通用化是从 VM 中删除计算机和用户特定信息的过程。Generalizing is a process that removes machine and user specific information from the VM. 对于 Windows,使用 Sysprep 工具。For Windows, the Sysprep tool is used. 对于 Linux,可以使用 waagent -deprovision-deprovision+user 参数。For Linux, you can use waagent -deprovision or -deprovision+user parameters.

专用化 VM 尚未经历删除计算机特定信息和帐户的过程。Specialized VMs have not been through a process to remove machine specific information and accounts. 此外,使用专用映像创建的 VM 不具有与其关联的 osProfileAlso, VMs created from specialized images do not have an osProfile associated with them. 这意味着,除了某些优点外,专用化映像还存在一些限制。This means that specialized images will have some limitations in addition to some benefits.

  • 从专用映像创建的 VM 和规模集可以更快地启动并运行。VMs and scale sets created from specialized images can be up and running quicker. 由于它们是从已经开始启动的源创建的,因此从这些映像创建的 VM 启动速度会更快。Because they are created from a source that has already been through first boot, VMs created from these images boot faster.
  • 可用于登录到 VM 的帐户也可用于通过使用该 VM 创建的专用映像创建的任何 VM。Accounts that could be used to log into the VM can also be used on any VM created using the specialized image that is created from that VM.
  • VM 具有用于创建映像的 VM 的 计算机名VMs will have the Computer name of the VM the image was taken from. 应更改计算机名以避免冲突。You should change the computer name to avoid collisions.
  • osProfile 是使用 secrets 将某些敏感信息传递给 VM 的方式。The osProfile is how some sensitive information is passed to the VM, using secrets. 在使用 KeyVault、WinRM,以及在 osProfile 中使用 secrets 的其他功能时,这可能会导致出现问题。This may cause issues using KeyVault, WinRM and other functionality that uses secrets in the osProfile. 在某些情况下,可以使用托管服务标识 (MSI) 解决这些限制。In some cases, you can use managed service identities (MSI) to work around these limitations.

区域支持Regional Support

下表列出了 Azure 中国世纪互联中的源区域。Source regions are listed in the table below on Azure China 21Vianet.

源区域Source regions
中国东部 2China East 2 中国北部 2China North 2


使用共享映像库部署资源时,每个订阅存在限制:There are limits, per subscription, for deploying resources using Shared Image Galleries:

  • 每个区域的每个订阅限制为 100 个共享映像库100 shared image galleries, per subscription, per region
  • 每个区域的每个订阅限制为 1,000 个映像定义1,000 image definitions, per subscription, per region
  • 每个区域的每个订阅限制为 10,000 个映像版本10,000 image versions, per subscription, per region
  • 每个区域的每个订阅限制为 10 个映像版本副本10 image version replicas, per subscription, per region
  • 附加到映像的任何磁盘的大小必须小于或等于 1 TBAny disk attached to the image must be less than or equal to 1TB in size

有关详细信息,请参阅根据限制检查资源使用情况,以获取有关如何检查当前使用情况的示例。For more information, see Check resource usage against limits for examples on how to check your current usage.


使用共享映像库可以指定要让 Azure 保留的映像副本数。Shared Image Gallery allows you to specify the number of replicas you want Azure to keep of the images. 这有助于实现多 VM 部署方案,因为可将 VM 部署分散到不同的副本,减少单个副本过载导致实例创建过程受到限制的可能性。This helps in multi-VM deployment scenarios as the VM deployments can be spread to different replicas reducing the chance of instance creation processing being throttled due to overloading of a single replica.

现在,使用共享映像库,最多可在虚拟机规模集中部署 1,000 个 VM 实例(相比使用托管映像部署 600 个有所增加)。With Shared Image Gallery, you can now deploy up to a 1,000 VM instances in a virtual machine scale set (up from 600 with managed images). 映像副本可用于提高部署性能、可靠性和一致性。Image replicas provide for better deployment performance, reliability and consistency.  可以在每个目标区域中设置不同的副本计数,具体视该区域的缩放需求而定。You can set a different replica count in each target region, based on the scale needs for the region. 由于每个副本是映像的深层复制,因此,这有助于使用每个额外的副本线性地缩放部署。Since each replica is a deep copy of your image, this helps scale your deployments linearly with each extra replica. 虽然我们了解没有两个映像或区域是相同的,但是,需要遵循下面有关如何在区域中使用副本的一般原则:While we understand no two images or regions are the same, here's our general guideline on how to use replicas in a region:

  • 对于非虚拟机规模集部署 - 建议为每 20 个同时创建的 VM 保留一个副本。For non-Virtual Machine Scale Set deployments - For every 20 VMs that you create concurrently, we recommend you keep one replica. 例如,如果使用某个区域中的同一映像同时创建 120 个 VM,我们建议你保留至少 6 个映像副本。For example, if you are creating 120 VMs concurrently using the same image in a region, we suggest you keep at least 6 replicas of your image.
  • 对于虚拟机规模集部署 - 建议为每个包含多达 600 个实例的规模集部署至少保留一个副本。For Virtual Machine Scale Set deployments - For every scale set deployment with up to 600 instances, we recommend you keep at least one replica. 例如,如果同时创建 5 个规模集,每个规模集具有 600 个使用某个区域中的同一映像的 VM 实例,则建议至少保留 5 个映像副本。For example, if you are creating 5 scale sets concurrently, each with 600 VM instances using the same image in a single region, we suggest you keep at least 5 replicas of your image.

鉴于映像大小、内容和 OS 类型等因素,我们始终建议保留的副本数应超出该副本数。We always recommend you to overprovision the number of replicas due to factors like image size, content and OS type.



使用共享映像库还可以自动将映像复制到其他 Azure 区域。Shared Image Gallery also allows you to replicate your images to other Azure regions automatically. 可以根据组织的需要,将每个共享映像版本复制到不同的区域。Each Shared Image version can be replicated to different regions depending on what makes sense for your organization. 例如,始终在多个区域复制最新的映像,而只在 1 个区域提供所有旧版本。One example is to always replicate the latest image in multi-regions while all older versions are only available in 1 region. 这有助于节省共享映像版本的存储成本。This can help save on storage costs for Shared Image versions.

创建共享映像版本后,可以更新该版本要复制到的区域。The regions a Shared Image version is replicated to can be updated after creation time. 复制到不同区域所需的时间取决于要复制的数据量,以及该版本要复制到的区域数。The time it takes to replicate to different regions depends on the amount of data being copied and the number of regions the version is replicated to. 在某些情况下,这可能需要几个小时。This can take a few hours in some cases. 在复制期间,可以查看每个区域的复制状态。While the replication is happening, you can view the status of replication per region. 在一个区域中完成映像复制后,接着可以在该区域中使用该映像版本部署 VM 或规模集。Once the image replication is complete in a region, you can then deploy a VM or scale-set using that image version in the region.



由于共享映像库、映像定义和映像版本都是资源,因此,可以使用内置的本机 Azure RBAC 控件来共享这些资源。As the Shared Image Gallery, Image Definition, and Image version are all resources, they can be shared using the built-in native Azure RBAC controls. 使用 RBAC 可与其他用户、服务主体和组共享这些资源。Using RBAC you can share these resources to other users, service principals, and groups. 甚至可以与创建这些资源的租户外部的个人共享访问权限。You can even share access to individuals outside of the tenant they were created within. 一旦用户有权访问共享的映像版本,他们就可以部署 VM 或虚拟机规模集。Once a user has access to the Shared Image version, they can deploy a VM or a Virtual Machine Scale Set. 以下共享矩阵可以帮助你了解用户有权访问哪些资源:Here is the sharing matrix that helps understand what the user gets access to:

与用户共享Shared with User 共享的映像库Shared Image Gallery 映像定义Image Definition 映像版本Image version
共享的映像库Shared Image Gallery Yes Yes Yes
映像定义Image Definition No Yes Yes

建议在库级别共享以获得最佳体验。We recommend sharing at the Gallery level for the best experience. 我们建议不要共享单个映像版本。We do not recommend sharing individual image versions. 有关 RBAC 的详细信息,请参阅使用 RBAC 管理对 Azure 资源的访问权限For more information about RBAC, see Manage access to Azure resources using RBAC.

此外,还可以使用多租户应用注册大规模共享映像,甚至是跨租户共享。Images can also be shared, at scale, even across tenants using a multi-tenant app registration. 有关在租户之间共享映像的详细信息,请参阅“如何使用 Azure CLIPowerShell 在 Azure 租户之间共享库 VM 映像”。For more information about sharing images across tenants, see "Share gallery VM images across Azure tenants" using the Azure CLI or PowerShell.


使用共享映像库服务不会产生额外的费用。There is no extra charge for using the Shared Image Gallery service. 以下资源会产生费用:You will be charged for the following resources:

  • 存储每个副本的存储成本。Storage costs of storing each replica. 存储按快照收费,基于映像版本的占用大小、映像版本的副本数量以及将版本复制到的区域数。The storage cost is charged as a snapshot and is based on the occupied size of the image version, the number of replicas of the image version and the number of regions the version is replicated to.
  • 将第一个映像版本从源区域复制到目标区域的网络传出费用。Network egress charges for replication of the first image version from the source region to the replicated regions. 后续副本将在区域中处理,因此不会产生额外的费用。Subsequent replicas are handled within the region, so there are no additional charges.

例如,假设你有一个 127 GB 的 OS 磁盘的映像,它只占用 10 GB 的存储空间,还有一个 32 GB 的空数据磁盘。For example, let's say you have an image of a 127 GB OS disk, that only occupies 10GB of storage, and one empty 32 GB data disk. 每个映像的占用大小仅为 10 GB。The occupied size of each image would only be 10 GB. 将映像复制到 3 个区域,每个区域有两个副本。The image is replicated to 3 regions and each region has two replicas. 总共有 6 个快照,每个快照使用 10 GB。There will be six total snapshots, each using 10GB. 将根据 10 GB 的占用大小向你收取每个快照的存储成本。You will be charged the storage cost for each snapshot based on the occupied size of 10 GB. 你将为要复制到另外两个区域的第一个副本支付网络流出量费用。You will pay network egress charges for the first replica to be copied to the additional two regions. 有关每个区域中快照定价的详细信息,请参阅托管磁盘定价For more information on the pricing of snapshots in each region, see Managed disks pricing. 有关网络流出量的详细信息,请参阅带宽定价For more information on network egress, see Bandwidth pricing.

正在更新资源Updating resources

创建后,可对映像库资源进行一些更改。Once created, you can make some changes to the image gallery resources. 限制如下:These are limited to:

共享映像库:Shared image gallery:

  • 说明Description

映像定义:Image definition:

  • 建议的 vCPU 数Recommended vCPUs
  • 建议的内存Recommended memory
  • 说明Description
  • 生命周期终结日期End of life date

映像版本:Image version:

  • 区域副本计数Regional replica count
  • 目标区域数Target regions
  • 从最新版本中排除Exclude from latest
  • 生命周期终结日期End of life date

SDK 支持SDK support

以下 SDK 支持创建共享映像库:The following SDKs support creating Shared Image Galleries:


可以使用模板创建共享映像库资源。You can create Shared Image Gallery resource using templates. 提供多个 Azure 快速入门模板:There are several Azure Quickstart Templates available:

常见问题Frequently asked questions

若要在 Azure 门户上列出不同订阅中你有权访问的所有共享映像库资源,请执行以下步骤:To list all the Shared Image Gallery resources across subscriptions that you have access to on the Azure portal, follow the steps below:

  1. 打开 Azure 门户Open the Azure portal.
  2. 向下滚动页面然后选择“所有资源”。Scroll down the page and select All resources.
  3. 选择要列出其中的所有资源的所有订阅。Select all the subscriptions under which you'd like to list all the resources.
  4. 查找类型为“共享映像库”的资源。Look for resources of type Shared image gallery.

若要列出不同订阅中你有权访问的所有共享映像库资源,请在 Azure CLI 中使用以下命令:To list all the Shared Image Gallery resources across subscriptions that you have permissions to, use the following command in the Azure CLI:

az account list -otsv --query "[].id" | xargs -n 1 az sig list --subscription

有关详细信息,请参阅使用 Azure CLIPowerShell 管理库资源。For more information, see Manage gallery resources using the Azure CLI or PowerShell.

是的。Yes. 根据映像的类型,可能存在 3 种场景。There are 3 scenarios based on the types of images you may have.

应用场景 1:如果你有托管映像,则可以从该映像创建映像定义和映像版本。Scenario 1: If you have a managed image, then you can create an image definition and image version from it. 有关详细信息,请参阅使用 Azure CLIPowerShell 从托管映像迁移到映像版本。For more information, see Migrate from a managed image to an image version using the Azure CLI or PowerShell.

应用场景 2:如果你有非托管的映像,可以从该映像创建托管映像,然后从该托管映像创建映像定义和映像版本。Scenario 2: If you have an unmanaged image, you can create a managed image from it, and then create an image definition and image version from it.

应用场景 3:如果本地文件系统中包含 VHD,则需要将 VHD 上传到托管映像,然后可以从该映像创建映像定义和映像版本。Scenario 3: If you have a VHD in your local file system, then you need to upload the VHD to a managed image, then you can create an image definition and image version from it.

是否可以从专用化磁盘创建映像版本?Can I create an image version from a specialized disk?

是的,可以使用 CLIPowerShell 或 API 从专用映像创建 VM。Yes, can create a VM from a specialized image using the CLI, PowerShell, or API.

不可以,无法将共享映像库资源移到其他订阅。No, you can't move the shared image gallery resource to a different subscription. 可以将库中的映像版本复制到其他区域,也可以使用 Azure CLIPowerShell 从其他库复制映像。You can replicate the image versions in the gallery to other regions or copy an image from another gallery using the Azure CLI or PowerShell.

是否可以跨云(例如 Azure 中国世纪互联、Azure 德国或 Azure 政府云)复制映像版本?Can I replicate my image versions across clouds such as Azure China 21Vianet or Azure Germany or Azure Government Cloud?

无法跨云复制映像版本。No, you cannot replicate image versions across clouds.

是否可以跨订阅复制映像版本?Can I replicate my image versions across subscriptions?

不可以。但可以跨订阅中的区域复制映像版本,并通过 RBAC 在其他订阅中使用该版本。No, you may replicate the image versions across regions in a subscription and use it in other subscriptions through RBAC.

是否可以跨 Azure AD 租户共享映像版本?Can I share image versions across Azure AD tenants?

是的,可以使用 RBAC 跨租户共享给个人。Yes, you can use RBAC to share to individuals across tenants. 但若要大规模共享,请参阅使用 PowerShellCLI“跨 Azure 租户共享库映像”。But, to share at scale, see "Share gallery images across Azure tenants" using PowerShell or CLI.

跨目标区域复制映像版本需要多长时间?How long does it take to replicate image versions across the target regions?

映像版本复制时间完全取决于映像的大小,以及它要复制到的区域数。The image version replication time is entirely dependent on the size of the image and the number of regions it is being replicated to. 但是,作为最佳做法,我们建议缩小映像,并在相互靠近的源与目标区域之间进行复制,以获得最佳效果。However, as a best practice, it is recommended that you keep the image small, and the source and target regions close for best results. 可以使用 -ReplicationStatus 标志检查复制状态。You can check the status of the replication using the -ReplicationStatus flag.

源区域与目标区域之间的区别是什么?What is the difference between source region and target region?

源区域是创建映像版本的区域,而目标区域是存储映像版本副本的区域。Source region is the region in which your image version will be created, and target regions are the regions in which a copy of your image version will be stored. 每个映像版本只能有一个源区域。For each image version, you can only have one source region. 此外,在创建映像版本时,请确保将源区域位置传递为目标区域之一。Also, make sure that you pass the source region location as one of the target regions when you create an image version.

创建映像版本时如何指定源区域?How do I specify the source region while creating the image version?

创建映像版本时,可以在 CLI 中使用 -location 标记或者在 PowerShell 中使用 -Location 标记,来指定源区域。While creating an image version, you can use the --location tag in CLI and the -Location tag in PowerShell to specify the source region. 请确保要用作基本映像来创建映像版本的托管映像,位于创建映像版本的同一位置。Please ensure the managed image that you are using as the base image to create the image version is in the same location as the location in which you intend to create the image version. 此外,在创建映像版本时,请确保将源区域位置传递为目标区域之一。Also, make sure that you pass the source region location as one of the target regions when you create an image version.

如何指定要在每个区域中创建的映像版本副本数?How do I specify the number of image version replicas to be created in each region?

可通过两种方式指定要在每个区域中创建的映像版本副本数:There are two ways you can specify the number of image version replicas to be created in each region:

  1. 区域副本计数:指定要在每个区域创建的副本数。The regional replica count which specifies the number of replicas you want to create per region.
  2. 通用副本计数:未指定区域副本计数时每个区域的默认计数。The common replica count which is the default per region count in case regional replica count is not specified.

若要指定区域副本计数,请传递位置以及要在该区域中创建的副本数:"China East=2"。To specify the regional replica count, pass the location along with the number of replicas you want to create in that region: "China East=2".

如果未为每个位置指定区域副本计数,则默认副本数将是指定的通用副本计数。If regional replica count is not specified with each location, then the default number of replicas will be the common replica count that you specified.

若要在 CLI 中指定通用副本计数,请在 az sig image-version create 命令中使用 --replica-count 参数。To specify the common replica count in CLI, use the --replica-count argument in the az sig image-version create command.

是,可以这样做。Yes, it is possible. 但作为最佳做法,我们建议将资源组、共享映像库、映像定义和映像版本保留在同一位置。But, as a best practice, we encourage you to keep the resource group, shared image gallery, image definition, and image version in the same location.

使用共享映像库服务不会产生费用,不过,存储映像版本会产生存储费用,将映像版本从源区域复制到目标区域会产生网络传出费用。There are no charges for using the Shared Image Gallery service, except the storage charges for storing the image versions and network egress charges for replicating the image versions from source region to target regions.

若要处理共享映像库、映像定义和映像版本,我们建议使用 API 版本 2018-06-01。To work with shared image galleries, image definitions, and image versions, we recommend you use API version 2018-06-01.

应使用哪个 API 版本基于映像版本创建共享 VM 或虚拟机规模集?What API version should I use to create Shared VM or Virtual Machine Scale Set out of the Image Version?

若要使用映像版本部署 VM 和虚拟机规模集,我们建议使用 API 2018-04-01 或更高版本。For VM and Virtual Machine Scale Set deployments using an image version, we recommend you use API version 2018-04-01 or higher.

是的,你可以将规模集映像引用从托管映像更新为共享映像库映像,前提是这些映像之间的 OS 类型、Hyper-V 生成和数据磁盘布局均匹配。Yes, you can update the scale set image reference from a managed image to a shared image gallery image, as long as the the OS type, Hyper-V generation, and the data disk layout matches between the images.

后续步骤Next steps

了解如何使用 Azure CLIPowerShell 部署共享映像。Learn how to deploy shared images using the Azure CLI or PowerShell.