New-AzGalleryImageVersion

建立資源庫映射版本。

Syntax

New-AzGalleryImageVersion
   [-ResourceGroupName] <String>
   [-GalleryName] <String>
   [-GalleryImageDefinitionName] <String>
   [-Name] <String>
   [-AsJob]
   -Location <String>
   [-DataDiskImage <GalleryDataDiskImage[]>]
   [-OSDiskImage <GalleryOSDiskImage>]
   [-PublishingProfileEndOfLifeDate <DateTime>]
   [-PublishingProfileExcludeFromLatest]
   [-ReplicaCount <Int32>]
   [-SourceImageId <String>]
   [-StorageAccountType <String>]
   [-Tag <Hashtable>]
   [-TargetRegion <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

建立資源庫映射版本。

範例

範例 1:從虛擬機器建立映射版本

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$sourceImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/virtualMachines/myVM"
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -SourceImageId $sourceImageId

將虛擬機器的新映射版本新增至映射定義。

範例 2:從受控映射建立映射版本

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$sourceImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myImageRG/providers/Microsoft.Compute/images/myImage"
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -SourceImageId $sourceImageId

將受控映射的新映射版本新增至映射定義。

範例 3:從另一個映射版本建立映射版本

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$sourceImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myImageRG/providers/Microsoft.Compute/galleries/myOtherGallery/images/myImageDefinition/versions/1.0.0"
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -SourceImageId $sourceImageId

將映射版本複製到另一個映射版本

範例 4:從受控磁片新增映射版本

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$osDisk = @{Source = @{Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myDiskRG/providers/Microsoft.Compute/disks/myOSDisk" }}
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -OSDiskImage $osDisk

從受控磁片建立映射版本

範例 5:從受控磁片新增映射版本,並新增其他資料磁片

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$osDisk = @{Source = @{Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myDiskRG/providers/Microsoft.Compute/disks/myOSDisk" }}
$dataDisk0 = @{Source = @{Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myDiskRG/providers/Microsoft.Compute/disks/myDataDisk" }; Lun = 0; }
$dataDisks = @($dataDisk0)
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -OSDiskImage $osDisk  -DataDiskImage $dataDisks

藉由指定 OS 和資料磁片來建立映射版本

範例 6:從 OS 磁片的快照集新增映射版本

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$osSnapshot = @{Source = @{Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mySnapshotRG/providers/Microsoft.Compute/snapshots/myOSSnapshot" }}
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -OSDiskImage $osDisk

從磁片快照集建立映射版本

範例 7:從 OS 磁片的快照集新增映射版本,並新增其他資料磁片

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$osSnapshot = @{Source = @{Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mySnapshotRG/providers/Microsoft.Compute/snapshots/myOSSnapshot" }}
$dataSnapshot0 = @{Source = @{Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mySnapshotRG/providers/Microsoft.Compute/snapshots/myDataSnapshot" }; Lun = 0; }
$dataDisks = @($dataSnapshot0)
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -OSDiskImage $osSnapshot  -DataDiskImage $dataDisks

指定 OS 和資料磁片的快照集,以建立映射版本。

範例 8:從磁片和快照集的組合新增映射版本

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$osSnapshot = @{Source = @{Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mySnapshotRG/providers/Microsoft.Compute/snapshots/myOSSnapshot" }}
$dataDisk0 = @{Source = @{Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myDiskRG/providers/Microsoft.Compute/disks/myDataDisk" }; Lun = 0; }
$dataDisks = @($dataDisk0)
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -OSDiskImage $osSnapshot  -DataDiskImage $dataDisks

藉由將快照集指定為 OS 磁片,並將受控磁片指定為數據磁片,以建立映射版本。

範例 9:新增映射版本,並將其複製到其他區域。

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"

$sourceImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/virtualMachines/myVM"
$replicaCount = 1
$storageAccountType = "Standard_ZRS"

$region_eastus = @{Name = 'East US';ReplicaCount = 3;StorageAccountType = 'Standard_LRS'}
$region_westus = @{Name = 'West US'}
$region_ukwest = @{Name = 'UK West';ReplicaCount = 2}
$region_southcentralus = @{Name = 'South Central US';StorageAccountType = 'Standard_LRS'}

$targetRegions = @($region_eastus, $region_westus, $region_ukwest, $region_southcentralus)

New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -SourceImageId $sourceImageId -ReplicaCount 1 -StorageAccountType $storageAccountType -TargetRegion $targetRegions

在四個區域中建立映射版本。 在此範例中,全域複本計數為 1,且全域儲存體帳戶類型為 Standard_ZRS。 美國東部會有 3 個複本,每個複本都儲存在Standard_LRS帳戶儲存體上。 美國西部會繼承自全域設定,並將 1 個複本儲存在Standard_ZRS上。 英國西部的複本計數為 2 個儲存在Standard_ZRS上。 美國中南部將有一個複本儲存在Standard_LRS上。

範例 10:在多個區域中新增具有加密的新映射版本

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$sourceImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/virtualMachines/myVM"
$replicaCount = 1
$storageAccountType = "Standard_ZRS"

# East US regional settings
$eastUSdes = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myDESrg/providers/Microsoft.Compute/diskEncryptionSets/myEastUSDES"
$encryption_eastus_os = @{DiskEncryptionSetId = $eastUSdes }
$encryption_eastus_dd0 = @{DiskEncryptionSetId = $eastUSdes; Lun = 0 }
$encryption_eastus_dd = @($encryption_eastus_dd0)
$eastus_encryption = @{OSDiskImage = $eastus_encryption_os; DataDiskImages = $eastus_encryption_dd }
$region_eastus = @{Name = 'East US';ReplicaCount = 3;StorageAccountType = 'Standard_LRS'; Encryption = $encryption_eastus}

# West US regional settings
$westUS2des = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myDESrg/providers/Microsoft.Compute/diskEncryptionSets/myWestUSDES"
$encryption_westus_os = @{DiskEncryptionSetId = $westUSdes }
$encryption_westus_dd0 = @{DiskEncryptionSetId = $westUSdes; Lun = 0 }
$encryption_westus_dd = @($encryption_westus_dd0)
$westus_encryption = @{OSDiskImage = $encryption_westus_os; DataDiskImages = $encryption_westus_dd }
$region_westus = @{Name = 'West US'; Encryption = $westus_encryption}

# Create images
$targetRegions = @($region_eastus, $region_westus)
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -SourceImageId $sourceImageId -TargetRegion $targetRegions

在兩個區域中建立具有加密的映射版本。 磁片加密集是區域資源,而且每個區域都必須使用不同的磁片加密集。

範例 11:建立映射版本,並將它從最新排除

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -SourceImageId $sourceImageId -PublishingProfileExcludeFromLatest

將新的映射版本新增至映射定義,但將其排除為其映射定義內的最新版本。

範例 12:建立映射版本並設定其生命循環結束日期

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "myImage"
$galleryImageVersionName = "1.0.0"
$location = "eastus"
$endOfLifeDate = "2024-08-02T00:00:00+00:00"
New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -SourceImageId $sourceImageId -PublishingProfileEndOfLifeDate $endOfLifeDate

此範例將映射版本的生命循環結束日期設定為 2024 年 8 月 2 日,于 mignight UTC。 您可以針對映射定義和映射版本指定生命循環結束日期。 映射版本仍可在生命循環結束日期之後使用。

範例 13:建立機密 VM 的映射版本

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "cvmImage"
$galleryImageVersionName = "1.0.0"
$location = "North Europe"

$sourceImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/virtualMachines/myVM"
$cvmDiskEncryptionSetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/diskEncryptionSets/cvmDiskEncryptionSet"
$dataDiskEncryptionSetId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/diskEncryptionSets/dataDiskEncryptionSet"

$cvmOsDiskEncryption = @{CVMEncryptionType='EncryptedWithCmk'; CVMDiskEncryptionSetID=$cvmDiskEncryptionSetId}

$cvmDataDiskEncryption_lun0 = @{DiskEncryptionSetId = $dataDiskEncryptionSetId ; Lun = 0}
$cvmDataDiskEncryption = @($cvmDataDiskEncryption_lun0)

$cvmEncryption = @{OSDiskImage = $cvmOsDiskEncryption; DataDiskImages = $cvmDataDiskEncryption}
$region_northEurope = @{Name = 'NorthEurope';ReplicaCount = 3;StorageAccountType = 'Standard_LRS'; Encryption = $cvmEncryption}
$targetRegions = @($region_northEurope)

New-AzGalleryImageVersion -ResourceGroupName $rgName -GalleryName $galleryName -GalleryImageDefinitionName $galleryImageDefinitionName -Name $galleryImageVersionName -Location $location -SourceImageId $sourceImageId -ReplicaCount 1 -StorageAccountType "Standard_LRS" -TargetRegion $targetRegions

在此範例中,機密 VM (CVM) 映射與客戶管理的金鑰 (CMK) 是在支援 ConfidentialVM 安全性類型的映射定義下建立。

參數

-AsJob

在背景中執行 Cmdlet

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-Confirm

在執行 Cmdlet 前提示您確認。

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-DataDiskImage

資料磁片映射。 例如@{Source = @{Id = < source_id > };Lun = 1;SizeInGB = 100;HostCaching = 「ReadOnly」 }

Type:GalleryDataDiskImage[]
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-DefaultProfile

用於和 Azure 通訊的認證、帳戶、租用戶及訂用帳戶。

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

-GalleryImageDefinitionName

資源庫的名稱。

Type:String
Aliases:GalleryImageName
Position:2
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-GalleryName

資源庫的名稱。

Type:String
Position:1
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-Location

資源位置

Type:String
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-Name

資源庫映射版本的名稱。

Type:String
Aliases:GalleryImageVersionName
Position:3
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-OSDiskImage

OS 磁片映射,例如 @{Source = @{Id = < source_id > };SizeInGB = 100;HostCaching = 「ReadOnly」 }

Type:GalleryOSDiskImage
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-PublishingProfileEndOfLifeDate

資源庫映射版本的生命循環結束日期。

Type:DateTime
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-PublishingProfileExcludeFromLatest

如果已設定,虛擬機器從最新版本的映射定義部署將不會使用此映射版本。

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-ReplicaCount

每個區域要建立之映射版本的複本數目。

Type:Int32
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-ResourceGroupName

資源群組的名稱。

Type:String
Position:0
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-SourceImageId

要從中建立映射版本的來源映射識別碼。

Type:String
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-StorageAccountType

指定要用來儲存映射的儲存體帳戶類型。 這個屬性無法更新。 可用的值為 Standard_LRS、Standard_ZRS 和 Premium_LRS。

Type:String
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-Tag

資源標籤

Type:Hashtable
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-TargetRegion

要複寫映射版本的目的地區域。

Type:Hashtable[]
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 Cmdlet 並不會執行。

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False

輸入

String

Hashtable

Int32

SwitchParameter

DateTime

Hashtable[]

輸出

PSGalleryImageVersion