diff --git a/src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs b/src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs index 93b0cbd18936..5f9a1b2e9fdd 100644 --- a/src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs +++ b/src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs @@ -93,5 +93,12 @@ public void TestInVMAccessControlProfileVersion() TestRunner.RunTestScript("Test-InVMAccessControlProfileVersion"); } + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + public void TestGalleryImageDefinitionUpdateFeature() + { + TestRunner.RunTestScript("Test-GalleryImageDefinitionUpdateFeature"); + } + } } \ No newline at end of file diff --git a/src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1 b/src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1 index ace80dd54f6b..00fdbd3c2c37 100644 --- a/src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1 +++ b/src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1 @@ -1224,4 +1224,77 @@ function Test-InVMAccessControlProfileVersion # Cleanup Clean-ResourceGroup $rgname; } -} \ No newline at end of file +}} + +<# +.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 initial feature + $initialFeature = @{Name = 'SecurityType'; Value = 'TrustedLaunch'} + New-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName ` + -Name $definitionName -Location $location ` + -Publisher $skuDetails.Publisher -Offer $skuDetails.Offer -Sku $skuDetails.Sku ` + -OsState $osState -OsType $osType -Feature $initialFeature -ErrorAction Stop; + + $definition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName; + Assert-NotNull $definition; + Assert-AreEqual $definition.Name $definitionName; + + # Update with Feature using StartsAtVersion and AllowUpdateImage + $diskControllerFeature = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.GalleryImageFeature ` + -Property @{Name = 'DiskControllerTypes'; Value = 'SCSI'; StartsAtVersion = '4.0.0'} + $securityFeature = New-Object -TypeName Microsoft.Azure.Management.Compute.Models.GalleryImageFeature ` + -Property @{Name = 'SecurityType'; Value = 'TrustedLaunch'; StartsAtVersion = '4.0.0'} + $features = @($diskControllerFeature, $securityFeature); + + Update-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName ` + -Name $definitionName -Feature $features -AllowUpdateImage $true; + + # Verify the updated features + $updatedDefinition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $definitionName; + Assert-NotNull $updatedDefinition; + Assert-AreEqual $updatedDefinition.AllowUpdateImage $true; + Assert-AreEqual $updatedDefinition.Features.Count 2; + + $diskControllerUpdated = $updatedDefinition.Features | Where-Object { $_.Name -eq 'DiskControllerTypes' }; + Assert-NotNull $diskControllerUpdated; + Assert-AreEqual $diskControllerUpdated.Value 'SCSI'; + Assert-AreEqual $diskControllerUpdated.StartsAtVersion '4.0.0'; + + $securityUpdated = $updatedDefinition.Features | Where-Object { $_.Name -eq 'SecurityType' }; + Assert-NotNull $securityUpdated; + Assert-AreEqual $securityUpdated.Value 'TrustedLaunch'; + Assert-AreEqual $securityUpdated.StartsAtVersion '4.0.0'; + } + finally + { + # Cleanup + Clean-ResourceGroup $rgname; + } +} diff --git a/src/Compute/Compute/ChangeLog.md b/src/Compute/Compute/ChangeLog.md index 14e253d71429..995fe6e48c46 100644 --- a/src/Compute/Compute/ChangeLog.md +++ b/src/Compute/Compute/ChangeLog.md @@ -20,6 +20,8 @@ --> ## Upcoming Release +* Added `-Feature` parameter to `Update-AzGalleryImageDefinition` cmdlet to allow updating existing gallery image features (such as DiskControllerTypes, SecurityType, IsAcceleratedNetwork, and IsHibernate). Each feature supports a `StartsAtVersion` property to specify the minimum gallery image version that supports the updated feature. +* Added `-AllowUpdateImage` parameter to `Update-AzGalleryImageDefinition` cmdlet. Must be set to `$true` when using the `-Feature` parameter to update gallery image features. ## Version 11.4.0 * Added `-DiskIOPSReadWrite` and `-DiskMBpsReadWrite` parameters to `Add-AzVMDataDisk` cmdlet diff --git a/src/Compute/Compute/Generated/GalleryImage/GalleryImageCreateOrUpdateMethod.cs b/src/Compute/Compute/Generated/GalleryImage/GalleryImageCreateOrUpdateMethod.cs index 827e1b0cf8f0..d0ca8b377221 100644 --- a/src/Compute/Compute/Generated/GalleryImage/GalleryImageCreateOrUpdateMethod.cs +++ b/src/Compute/Compute/Generated/GalleryImage/GalleryImageCreateOrUpdateMethod.cs @@ -521,6 +521,20 @@ public override void ExecuteCmdlet() galleryImage.PurchasePlan.Product = this.PurchasePlanProduct; } + if (this.IsParameterBound(c => c.Feature)) + { + galleryImage.Features = new List(); + for (int i = 0; i < this.Feature.Length; i++) + { + galleryImage.Features.Add(this.Feature[i]); + } + } + + if (this.IsParameterBound(c => c.AllowUpdateImage)) + { + galleryImage.AllowUpdateImage = this.AllowUpdateImage; + } + var result = GalleryImagesClient.CreateOrUpdate(resourceGroupName, galleryName, galleryImageName, galleryImage); var psObject = new PSGalleryImage(); ComputeAutomationAutoMapperProfile.Mapper.Map(result, psObject); @@ -639,5 +653,17 @@ public override void ExecuteCmdlet() Mandatory = false, ValueFromPipelineByPropertyName = true)] public Hashtable Tag { get; set; } + + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "A list of gallery image features to update. Each feature can include a StartsAtVersion property to indicate the minimum gallery image version that supports it.")] + public GalleryImageFeature[] Feature { get; set; } + + [Parameter( + Mandatory = false, + ValueFromPipelineByPropertyName = true, + HelpMessage = "Must be set to true if the gallery image features are being updated.")] + public bool AllowUpdateImage { get; set; } } } diff --git a/src/Compute/Compute/Generated/Models/PSGalleryImage.cs b/src/Compute/Compute/Generated/Models/PSGalleryImage.cs index 018b4df25dd4..1749eb0782cc 100644 --- a/src/Compute/Compute/Generated/Models/PSGalleryImage.cs +++ b/src/Compute/Compute/Generated/Models/PSGalleryImage.cs @@ -59,6 +59,7 @@ public string ResourceGroupName public string Location { get; set; } public IDictionary Tags { get; set; } public IList Features { get; set; } + public bool? AllowUpdateImage { get; set; } public string Architecture { get; set; } } diff --git a/src/Compute/Compute/help/Update-AzGalleryImageDefinition.md b/src/Compute/Compute/help/Update-AzGalleryImageDefinition.md index 2b5ca755bddf..9c917a6f9b54 100644 --- a/src/Compute/Compute/help/Update-AzGalleryImageDefinition.md +++ b/src/Compute/Compute/help/Update-AzGalleryImageDefinition.md @@ -19,6 +19,7 @@ Update-AzGalleryImageDefinition [-ResourceGroupName] [-GalleryName] ] [-MinimumVCPU ] [-MaximumMemory ] [-MaximumVCPU ] [-PrivacyStatementUri ] [-PurchasePlanName ] [-PurchasePlanProduct ] [-PurchasePlanPublisher ] [-ReleaseNoteUri ] [-Tag ] + [-Feature ] [-AllowUpdateImage ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -29,7 +30,8 @@ Update-AzGalleryImageDefinition [-ResourceId] [-AsJob] [-Description ] [-EndOfLifeDate ] [-Eula ] [-MinimumMemory ] [-MinimumVCPU ] [-MaximumMemory ] [-MaximumVCPU ] [-PrivacyStatementUri ] [-PurchasePlanName ] [-PurchasePlanProduct ] [-PurchasePlanPublisher ] - [-ReleaseNoteUri ] [-Tag ] [-DefaultProfile ] + [-ReleaseNoteUri ] [-Tag ] [-Feature ] + [-AllowUpdateImage ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -39,7 +41,8 @@ Update-AzGalleryImageDefinition [-InputObject] [-AsJob] [-Descr [-DisallowedDiskType ] [-EndOfLifeDate ] [-Eula ] [-MinimumMemory ] [-MinimumVCPU ] [-MaximumMemory ] [-MaximumVCPU ] [-PrivacyStatementUri ] [-PurchasePlanName ] [-PurchasePlanProduct ] [-PurchasePlanPublisher ] - [-ReleaseNoteUri ] [-Tag ] [-DefaultProfile ] + [-ReleaseNoteUri ] [-Tag ] [-Feature ] + [-AllowUpdateImage ] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -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'} +$features = @($DiskControllerType, $SecurityType) +Update-AzGalleryImageDefinition -ResourceGroupName $rgName -GalleryName $galleryName -Name $imageDefinitionName -Feature $features -AllowUpdateImage $true +``` + +Update a gallery image definition's features, setting the minimum gallery image version that supports each feature via StartsAtVersion. The AllowUpdateImage parameter must be set to true when updating features. + ## PARAMETERS ### -AsJob @@ -383,6 +400,36 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -Feature +A list of gallery image features to update. Each feature can include a StartsAtVersion property to indicate the minimum gallery image version that supports it. + +```yaml +Type: Microsoft.Azure.Management.Compute.Models.GalleryImageFeature[] +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -AllowUpdateImage +Must be set to `$true` when the gallery image features are being updated using the `-Feature` parameter. + +```yaml +Type: System.Boolean +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -Confirm Prompts you for confirmation before running the cmdlet. @@ -431,6 +478,10 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable ### System.String[] +### Microsoft.Azure.Management.Compute.Models.GalleryImageFeature[] + +### System.Boolean + ## OUTPUTS ### Microsoft.Azure.Commands.Compute.Automation.Models.PSGalleryImage