Skip to content
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

TargetExtendedLocation support for GalleryImageVersion #20748

Merged
merged 8 commits into from
Jan 31, 2023
Merged
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
2 changes: 1 addition & 1 deletion src/Compute/Compute.Test/Compute.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="59.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="60.0.0" />
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="4.0.0-preview.1" />
<PackageReference Include="Microsoft.Azure.Management.Network" Version="25.0.0" />
</ItemGroup>
Expand Down
10 changes: 8 additions & 2 deletions src/Compute/Compute.Test/ScenarioTests/ComputeTestCommon.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ Gets default CRP Image
#>
function Get-DefaultCRPImage
{
param([string] $loc = "westus", [string] $query = '*Microsoft*Windows*Server*')
param([string] $loc = "westus", [string] $query = '*Microsoft*Windows*Server*', [bool] $New = $False)

$result = (Get-AzVMImagePublisher -Location $loc) | select -ExpandProperty PublisherName | where { $_ -like $query };
if ($result.Count -eq 1)
Expand All @@ -495,7 +495,12 @@ function Get-DefaultCRPImage
$defaultOffer = $result[0];
}

$result = (Get-AzVMImageSku -Location $loc -PublisherName $defaultPublisher -Offer $defaultOffer) | select -ExpandProperty Skus;
if ($New -eq $True){
$result = (Get-AzVMImageSku -Location $loc -PublisherName $defaultPublisher -Offer $defaultOffer) | select -ExpandProperty Skus| where { $_ -like '*2022-datacenter*'};
}
else {
$result = (Get-AzVMImageSku -Location $loc -PublisherName $defaultPublisher -Offer $defaultOffer) | select -ExpandProperty Skus;
}
if ($result.Count -eq 1)
{
$defaultSku = $result;
Expand All @@ -517,6 +522,7 @@ function Get-DefaultCRPImage

$vmimg = Get-AzVMImage -Location $loc -Offer $defaultOffer -PublisherName $defaultPublisher -Skus $defaultSku -Version $defaultVersion;


return $vmimg;
}

Expand Down
23 changes: 17 additions & 6 deletions src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ function Test-GalleryImageVersion
$maxVCPU = 32;
$purchasePlanName = "purchasePlanName";
$purchasePlanProduct = "purchasePlanProduct";
$purchasePlanPublisher = "";
$purchasePlanPublisher = "20";
$osState = "Generalized";
$osType = "Windows";

Expand Down Expand Up @@ -502,7 +502,7 @@ function Test-GalleryImageVersion
$galleryImageVersionName = "1.0.0";

# Create a VM first
$vmsize = 'Standard_A4';
$vmsize = 'Standard_A2_v2';
$vmname = 'vm' + $rgname;
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize;
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
Expand Down Expand Up @@ -548,7 +548,7 @@ function Test-GalleryImageVersion
# $p.StorageProfile.OSDisk = $null;
$p = Set-AzVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;

$imgRef = Get-DefaultCRPImage -loc $loc;
$imgRef = Get-DefaultCRPImage -loc $loc -New $True;
$p = ($imgRef | Set-AzVMSourceImage -VM $p);

# Virtual Machine
Expand All @@ -565,26 +565,37 @@ function Test-GalleryImageVersion
$targetRegions = @(@{Name='South Central US';ReplicaCount=1;StorageAccountType='Standard_LRS'},@{Name='East US';ReplicaCount=2},@{Name='Central US'});
$tag = @{test1 = "testval1"; test2 = "testval2" };

# Set TargetExtendedLocation
$storageAccountType = "Standard_LRS"
$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 $galleryImageName -Name $galleryImageVersionName `
-Location $loc -SourceImageId $image.Id -ReplicaCount 1 `
-PublishingProfileEndOfLifeDate $endOfLifeDate `
-StorageAccountType Standard_LRS `
-TargetRegion $targetRegions;
-TargetRegion $targetRegions -TargetExtendedLocation $targetExtendedLocations;

# Check TargetExtendedLocation
$version = Get-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName;
Verify-GalleryImageVersion $version $rgname $galleryImageVersionName $loc `
$image.Id 1 $endOfLifeDate $targetRegions;
Assert-AreEqual $version.PublishingProfile.TargetExtendedLocations.count 1

# remove TargetExtendedLocation
Update-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName `
-Tag $tag;
-Tag $tag -TargetExtendedLocation @() -AllowDeletionOfReplicatedLocation $True;

$version = Get-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName;
Verify-GalleryImageVersion $version $rgname $galleryImageVersionName $loc `
$image.Id 1 $endOfLifeDate $targetRegions;
$image.Id 1 $endOfLifeDate $targetRegions
# check TargetExtendedLocation count
Assert-AreEqual $version.PublishingProfile.TargetExtendedLocations.count 0

$version | Remove-AzGalleryImageVersion -Force;
Wait-Seconds 300;
Expand Down

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
* Filled in missing parameter descriptions across multiple parameters and improved some existing parameter descriptions.
* Updated Compute PS to use the new .Net SDK version 59.0.0. This includes an approved breaking change for a non-functional feature.
- The type of the property `Source` of type `Microsoft.Azure.Management.Compute.Models.GalleryDataDiskImage`, `Microsoft.Azure.Management.Compute.Models.GalleryOSDiskImage`, and `Microsoft.Azure.Management.Compute.Models.GalleryImageVersionStorageProfile` has changed from `Microsoft.Azure.Management.Compute.Models.GalleryArtifactVersionSource` to `Microsoft.Azure.Management.Compute.Models.GalleryDiskImageSource`.
* Added `-TargetExtendedLocation` parameter to `New-AzGalleryImageVersion` and `Update-AzGalleryImageVersion`
* Added `-AllowDeletionOfReplicatedLocation` to `Update-AzGalleryImageVersion`

## Version 5.3.0
* Removed the image `Win2008R2SP1` from the list of available images and documentation. This image is no longer available on the backend so the client tools need to sync to that change.
Expand Down
2 changes: 1 addition & 1 deletion src/Compute/Compute/Compute.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.PowerShell.AutoMapper" Version="6.2.2" />
<PackageReference Include="Microsoft.Azure.Management.ResourceGraph" Version="2.1.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="59.0.0" />
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="60.0.0" />
<PackageReference Include="System.Security.Permissions" Version="4.5.0" />
<PackageReference Include="System.ServiceModel.Primitives" Version="4.7.0" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.0" />
Expand Down
Loading