Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,12 @@ public void TestInVMAccessControlProfileVersion()
TestRunner.RunTestScript("Test-InVMAccessControlProfileVersion");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestGalleryImageDefinitionUpdateFeature()
{
TestRunner.RunTestScript("Test-GalleryImageDefinitionUpdateFeature");
}

}
}
75 changes: 74 additions & 1 deletion src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1224,4 +1224,77 @@ 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 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;
}
}
2 changes: 2 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
}

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<GalleryImage, PSGalleryImage>(result, psObject);
Expand Down Expand Up @@ -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; }
}
}
1 change: 1 addition & 0 deletions src/Compute/Compute/Generated/Models/PSGalleryImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public string ResourceGroupName
public string Location { get; set; }
public IDictionary<string, string> Tags { get; set; }
public IList<GalleryImageFeature> Features { get; set; }
public bool? AllowUpdateImage { get; set; }
public string Architecture { get; set; }

}
Expand Down
55 changes: 53 additions & 2 deletions src/Compute/Compute/help/Update-AzGalleryImageDefinition.md
Original file line number Diff line number Diff line change
Expand Up @@ -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>]
```
Expand All @@ -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>]
```

Expand All @@ -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>]
```

Expand All @@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
Loading