-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Copilot/az compute update galleryimage feature #29368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5ab9037
22f6ead
3a3a5cc
13d2dca
6aaa697
efac99c
f4bf63e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1224,4 +1224,82 @@ function Test-InVMAccessControlProfileVersion | |||||||||||||||||
| # Cleanup | ||||||||||||||||||
| Clean-ResourceGroup $rgname; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| <# | ||||||||||||||||||
| .SYNOPSIS | ||||||||||||||||||
| Tests updating gallery image definition features with StartsAtVersion and AllowUpdateImage parameters | ||||||||||||||||||
| #> | ||||||||||||||||||
| function Test-GalleryImageDefinitionUpdateFeature | ||||||||||||||||||
| { | ||||||||||||||||||
| # Setup | ||||||||||||||||||
| $rgname = Get-ComputeTestResourceName; | ||||||||||||||||||
| $loc = Get-ComputeVMLocation; | ||||||||||||||||||
|
|
||||||||||||||||||
| try | ||||||||||||||||||
| { | ||||||||||||||||||
| $location = $loc; | ||||||||||||||||||
| New-AzResourceGroup -Name $rgname -Location $loc -Force; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Gallery variables | ||||||||||||||||||
| $galleryName = 'gl' + $rgname; | ||||||||||||||||||
| $definitionName = 'def' + $rgname; | ||||||||||||||||||
| $skuDetails = @{ | ||||||||||||||||||
| Publisher = 'testpub' | ||||||||||||||||||
| Offer = 'testoffer' | ||||||||||||||||||
| Sku = 'testsku' | ||||||||||||||||||
| } | ||||||||||||||||||
| $osType = 'Windows' | ||||||||||||||||||
| $osState = 'Specialized' | ||||||||||||||||||
|
|
||||||||||||||||||
| # Create gallery | ||||||||||||||||||
| New-AzGallery -ResourceGroupName $rgname -Name $galleryName -Location $location; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Create image definition with features including StartsAtVersion | ||||||||||||||||||
| $initialSecurityFeature = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.GalleryImageFeature ` | ||||||||||||||||||
| -Property @{Name = 'SecurityType'; Value = 'TrustedLaunch'; StartsAtVersion = '4.0.0'} | ||||||||||||||||||
| $initialDiskControllerFeature = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.GalleryImageFeature ` | ||||||||||||||||||
| -Property @{Name = 'DiskControllerTypes'; Value = 'SCSI'; StartsAtVersion = '4.0.0'} | ||||||||||||||||||
| $initialFeatures = @($initialSecurityFeature, $initialDiskControllerFeature); | ||||||||||||||||||
|
|
||||||||||||||||||
| New-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName ` | ||||||||||||||||||
| -Name $definitionName -Location $location ` | ||||||||||||||||||
| -Publisher $skuDetails.Publisher -Offer $skuDetails.Offer -Sku $skuDetails.Sku ` | ||||||||||||||||||
| -OsState $osState -OsType $osType -Feature $initialFeatures -ErrorAction Stop; | ||||||||||||||||||
|
|
||||||||||||||||||
| $definition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName; | ||||||||||||||||||
| Assert-NotNull $definition; | ||||||||||||||||||
| Assert-AreEqual $definition.Name $definitionName; | ||||||||||||||||||
| Assert-AreEqual $definition.Features.Count 2; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Update with AllowUpdateImage using different feature values | ||||||||||||||||||
| $securityFeature = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.GalleryImageFeature ` | ||||||||||||||||||
| -Property @{Name = 'SecurityType'; Value = 'TrustedLaunch'; StartsAtVersion = '4.0.0'} | ||||||||||||||||||
| $diskControllerFeature = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.GalleryImageFeature ` | ||||||||||||||||||
| -Property @{Name = 'DiskControllerTypes'; Value = 'SCSI, NVMe'; StartsAtVersion = '4.0.0'} | ||||||||||||||||||
| $features = @($securityFeature, $diskControllerFeature); | ||||||||||||||||||
|
|
||||||||||||||||||
| Update-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName ` | ||||||||||||||||||
| -Name $definitionName -Feature $features -AllowUpdateImage $true; | ||||||||||||||||||
|
|
||||||||||||||||||
| # Verify the updated definition | ||||||||||||||||||
| $updatedDefinition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName; | ||||||||||||||||||
|
Comment on lines
+1283
to
+1286
|
||||||||||||||||||
| -Name $definitionName -Feature $features -AllowUpdateImage $true; | |
| # Verify the updated definition | |
| $updatedDefinition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName; | |
| -Name $definitionName -Feature $features -AllowUpdateImage $true -ErrorAction Stop; | |
| # Verify the updated definition | |
| $updatedDefinition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName -ErrorAction Stop; |
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -521,6 +521,20 @@ public override void ExecuteCmdlet() | |||||||||||||
| galleryImage.PurchasePlan.Product = this.PurchasePlanProduct; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if (this.IsParameterBound(c => c.Feature)) | ||||||||||||||
| { | ||||||||||||||
| galleryImage.Features = new List<GalleryImageFeature>(); | ||||||||||||||
| for (int i = 0; i < this.Feature.Length; i++) | ||||||||||||||
| { | ||||||||||||||
| galleryImage.Features.Add(this.Feature[i]); | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+526
to
+530
|
||||||||||||||
| galleryImage.Features = new List<GalleryImageFeature>(); | |
| for (int i = 0; i < this.Feature.Length; i++) | |
| { | |
| galleryImage.Features.Add(this.Feature[i]); | |
| } | |
| galleryImage.Features = this.Feature.ToList(); |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -19,6 +19,7 @@ Update-AzGalleryImageDefinition [-ResourceGroupName] <String> [-GalleryName] <St | |||||||||
| [-MinimumMemory <Int32>] [-MinimumVCPU <Int32>] [-MaximumMemory <Int32>] [-MaximumVCPU <Int32>] | ||||||||||
| [-PrivacyStatementUri <String>] [-PurchasePlanName <String>] [-PurchasePlanProduct <String>] | ||||||||||
| [-PurchasePlanPublisher <String>] [-ReleaseNoteUri <String>] [-Tag <Hashtable>] | ||||||||||
| [-Feature <GalleryImageFeature[]>] [-AllowUpdateImage <Boolean>] | ||||||||||
| [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] | ||||||||||
| [<CommonParameters>] | ||||||||||
| ``` | ||||||||||
|
|
@@ -29,7 +30,8 @@ Update-AzGalleryImageDefinition [-ResourceId] <String> [-AsJob] [-Description <S | |||||||||
| [-DisallowedDiskType <String[]>] [-EndOfLifeDate <DateTime>] [-Eula <String>] [-MinimumMemory <Int32>] | ||||||||||
| [-MinimumVCPU <Int32>] [-MaximumMemory <Int32>] [-MaximumVCPU <Int32>] [-PrivacyStatementUri <String>] | ||||||||||
| [-PurchasePlanName <String>] [-PurchasePlanProduct <String>] [-PurchasePlanPublisher <String>] | ||||||||||
| [-ReleaseNoteUri <String>] [-Tag <Hashtable>] [-DefaultProfile <IAzureContextContainer>] | ||||||||||
| [-ReleaseNoteUri <String>] [-Tag <Hashtable>] [-Feature <GalleryImageFeature[]>] | ||||||||||
| [-AllowUpdateImage <Boolean>] [-DefaultProfile <IAzureContextContainer>] | ||||||||||
| [-WhatIf] [-Confirm] [<CommonParameters>] | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
|
|
@@ -39,7 +41,8 @@ Update-AzGalleryImageDefinition [-InputObject] <PSGalleryImage> [-AsJob] [-Descr | |||||||||
| [-DisallowedDiskType <String[]>] [-EndOfLifeDate <DateTime>] [-Eula <String>] [-MinimumMemory <Int32>] | ||||||||||
| [-MinimumVCPU <Int32>] [-MaximumMemory <Int32>] [-MaximumVCPU <Int32>] [-PrivacyStatementUri <String>] | ||||||||||
| [-PurchasePlanName <String>] [-PurchasePlanProduct <String>] [-PurchasePlanPublisher <String>] | ||||||||||
| [-ReleaseNoteUri <String>] [-Tag <Hashtable>] [-DefaultProfile <IAzureContextContainer>] | ||||||||||
| [-ReleaseNoteUri <String>] [-Tag <Hashtable>] [-Feature <GalleryImageFeature[]>] | ||||||||||
| [-AllowUpdateImage <Boolean>] [-DefaultProfile <IAzureContextContainer>] | ||||||||||
| [-WhatIf] [-Confirm] [<CommonParameters>] | ||||||||||
| ``` | ||||||||||
|
|
||||||||||
|
|
@@ -66,6 +69,20 @@ Update-AzGalleryImageDefinition -ResourceGroupName $resourceGroupName -GalleryNa | |||||||||
|
|
||||||||||
| Update a gallery image definition's recommended configuration settings | ||||||||||
|
|
||||||||||
| ### Example 2: Update gallery image features with StartsAtVersion | ||||||||||
|
|
||||||||||
| ```powershell | ||||||||||
| $rgName = "myResourceGroup" | ||||||||||
| $galleryName = "myGallery" | ||||||||||
| $imageDefinitionName = "myImageDefinition" | ||||||||||
| $DiskControllerType = @{Name='DiskControllerTypes'; Value='SCSI'; StartsAtVersion='4.0.0'} | ||||||||||
| $SecurityType = @{Name='SecurityType'; Value='TrustedLaunch'; StartsAtVersion='4.0.0'} | ||||||||||
|
Comment on lines
+78
to
+79
|
||||||||||
| $DiskControllerType = @{Name='DiskControllerTypes'; Value='SCSI'; StartsAtVersion='4.0.0'} | |
| $SecurityType = @{Name='SecurityType'; Value='TrustedLaunch'; StartsAtVersion='4.0.0'} | |
| $DiskControllerType = New-Object Microsoft.Azure.Management.Compute.Models.GalleryImageFeature -Property @{Name='DiskControllerTypes'; Value='SCSI'; StartsAtVersion='4.0.0'} | |
| $SecurityType = New-Object Microsoft.Azure.Management.Compute.Models.GalleryImageFeature -Property @{Name='SecurityType'; Value='TrustedLaunch'; StartsAtVersion='4.0.0'} |
Uh oh!
There was an error while loading. Please reload this page.