New-AzGalleryImageVersion

Utwórz wersję obrazu galerii.

Składnia

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>]
   [-SourceImageVMId <String>]
   [-Tag <Hashtable>]
   [-TargetRegion <Hashtable[]>]
   [-TargetExtendedLocation <Hashtable[]>]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Opis

Utwórz wersję obrazu galerii.

Przykłady

Przykład 1. Tworzenie wersji obrazu na podstawie maszyny wirtualnej

$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

Dodaj nową wersję obrazu z maszyny wirtualnej do definicji obrazu.

Przykład 2. Tworzenie wersji obrazu na podstawie obrazu zarządzanego

$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"
$storageAccountType = "StandardSSD_LRS"

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

Dodaj nową wersję obrazu z obrazu zarządzanego do definicji obrazu.

Przykład 3. Tworzenie wersji obrazu z innej wersji obrazu

$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

Kopiowanie wersji obrazu do innej wersji obrazu

Przykład 4. Dodawanie nowej wersji obrazu z dysku zarządzanego

$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

Tworzenie wersji obrazu na podstawie dysku zarządzanego

Przykład 5. Dodawanie nowej wersji obrazu z dysku zarządzanego i dodawanie dodatkowych dysków danych

$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

Tworzenie wersji obrazu przez określenie dysków systemu operacyjnego i danych

Przykład 6. Dodawanie nowej wersji obrazu z migawki dysku systemu operacyjnego

$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 $osSnapshot

Tworzenie wersji obrazu na podstawie migawki dysku

Przykład 7. Dodawanie nowej wersji obrazu z migawki dysku systemu operacyjnego i dodawanie dodatkowych dysków danych

$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

Utwórz wersję obrazu, określając migawki dla dysków systemu operacyjnego i danych.

Przykład 8: Dodawanie nowej wersji obrazu z kombinacji dysków i migawek

$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

Utwórz wersję obrazu, określając migawkę jako dysk systemu operacyjnego i dysk zarządzany jako dysk danych.

Przykład 9. Dodaj nową wersję obrazu i skopiuj ją do dodatkowych regionów.

$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

Utwórz wersję obrazu w czterech regionach. W tym przykładzie liczba replik globalnych wynosi 1, a globalny typ konta magazynu jest Standard_ZRS. Wschodnie stany USA będą mieć 3 repliki, z których każda będzie przechowywana w magazynie konta Standard_LRS. Zachodnie stany USA dziedziczą ustawienia globalne i mają 1 replikę przechowywaną na Standard_ZRS. Zachodnia Wielka Brytania będzie miała liczbę replik 2 przechowywanych na Standard_ZRS. Południowo-środkowe stany USA będą miały jedną replikę przechowywaną na Standard_LRS.

Przykład 10: Dodawanie nowej wersji obrazu z szyfrowaniem w wielu regionach

$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

Utwórz wersję obrazu z szyfrowaniem w dwóch regionach. Zestawy szyfrowania dysków to zasoby regionalne, a w każdym regionie musi być używany inny zestaw szyfrowania dysków.

Przykład 11: Tworzenie wersji obrazu i wykluczenie jej z najnowszej wersji

$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

Dodaj nową wersję obrazu do definicji obrazu, ale wyklucz ją z rozważania dla najnowszej wersji w ramach definicji obrazu.

Przykład 12: Tworzenie wersji obrazu i ustawianie daty zakończenia życia

$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

Ten przykład zawiera datę zakończenia życia wersji obrazu ustawioną na 2 sierpnia 2024 r. o godzinie mignight utc. Daty zakończenia życia można określić dla definicji obrazów i wersji obrazów. Wersje obrazów mogą być nadal używane po datach zakończenia życia.

Przykład 13. Tworzenie wersji obrazu dla poufnej maszyny wirtualnej

$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

W tym przykładzie obraz poufnej maszyny wirtualnej (CVM) z kluczem zarządzanym przez klienta (CMK) jest tworzony w obszarze Definicja obrazu, która obsługuje typ zabezpieczeń ConfidentialVM.

Przykład 14. Tworzenie wersji obrazu z docelową lokalizacją rozszerzoną

$rgName = "myResourceGroup"
$galleryName = "myGallery"
$galleryImageDefinitionName = "cvmImage"
$galleryImageVersionName = "1.0.0"
$location = "EastUs"
$sourceImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myVMRG/providers/Microsoft.Compute/virtualMachines/myVM"

$replicaCount = 1  
$extendedLocation = @{Name = 'microsoftlosangeles1';Type='EdgeZone'}
$edgezone_losangeles = @{Location = "westus";ExtendedLocation=$extendedLocation;ReplicaCount = 3;StorageAccountType = 'StandardSSD_LRS'}  
$targetExtendedLocations = @($edgezone_losangeles) 

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

W tym przykładzie utworzono tabelę skrótu dla właściwości lokalizacji rozszerzonej obiektu docelowego i przekazuje parametr -TargetExtendedLocation.

Parametry

-AsJob

Uruchamianie polecenia cmdlet w tle

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

-Confirm

Monituje o potwierdzenie przed uruchomieniem polecenia cmdlet.

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

-DataDiskImage

Obrazy dysków danych. np. @{Źródło = @{Id = <source_id>}; Lun = 1; SizeInGB = 100; Host Buforowanie = "ReadOnly" }

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

-DefaultProfile

Poświadczenia, konto, dzierżawa i subskrypcja używane do komunikacji z platformą Azure.

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

-GalleryImageDefinitionName

Nazwa galerii.

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

-GalleryName

Nazwa galerii.

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

-Location

Lokalizacja zasobu

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

-Name

Nazwa wersji obrazu galerii.

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

-OSDiskImage

Obraz dysku systemu operacyjnego, np. @{Źródło = @{Id = <source_id>}; SizeInGB = 100; Host Buforowanie = "ReadOnly" }

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

-PublishingProfileEndOfLifeDate

Data zakończenia życia wersji obrazu galerii.

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

-PublishingProfileExcludeFromLatest

Jeśli jest ona ustawiona, maszyny wirtualne wdrożone z najnowszej wersji definicji obrazu nie będą używać tej wersji obrazu.

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

-ReplicaCount

Liczba replik wersji obrazu do utworzenia w poszczególnych regionach.

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

-ResourceGroupName

Nazwa grupy zasobów.

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

-SourceImageId

Identyfikator obrazu źródłowego, z którego ma zostać utworzona wersja obrazu.

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

-SourceImageVMId

Identyfikator zasobu źródłowej maszyny wirtualnej. Wymagane tylko podczas przechwytywania maszyny wirtualnej do źródła tej wersji obrazu galerii.

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

-StorageAccountType

Określa typ konta magazynu, który ma być używany do przechowywania obrazu. Ta właściwość nie jest aktualizowalna. Dostępne wartości to Standard_LRS, Standard_ZRS i Premium_LRS.

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

-Tag

Tagi zasobów

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

-TargetExtendedLocation

Docelowe lokalizacje rozszerzone, w których wersja obrazu ma zostać zreplikowana. Ta właściwość jest aktualizowalna.

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

-TargetRegion

Regiony docelowe, w których wersja obrazu ma zostać zreplikowana.

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

-WhatIf

Pokazuje, co się stanie po uruchomieniu polecenia cmdlet. Polecenie cmdlet nie zostało uruchomione.

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

Dane wejściowe

String

Hashtable

Int32

SwitchParameter

DateTime

Hashtable[]

Dane wyjściowe

PSGalleryImageVersion