Skip to content

Commit 8bb7287

Browse files
authored
Merge pull request #9079 from hyonholee/april2
[Compute] PPG cmdlets and others.
2 parents 9096a80 + 44bfa1a commit 8bb7287

File tree

275 files changed

+27418
-3740
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+27418
-3740
lines changed

src/Compute/Compute.Test/Compute.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.Azure.Graph.RBAC" Version="3.4.0-preview" />
15-
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="25.0.0" />
15+
<PackageReference Include="Microsoft.Azure.Management.Compute" Version="27.0.0" />
1616
<PackageReference Include="Microsoft.Azure.Management.KeyVault" Version="2.4.2" />
1717
<PackageReference Include="Microsoft.Azure.Management.Network" Version="19.11.0-preview" />
1818
</ItemGroup>

src/Compute/Compute.Test/ScenarioTests/AEMExtensionTests.ps1

Lines changed: 102 additions & 104 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/ScenarioTests/AvailabilitySetTests.ps1

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ function Test-AvailabilitySet
8181
Assert-AreEqual $aset.Name $asetName;
8282
Assert-AreEqual $nonDefaultUD $aset.PlatformUpdateDomainCount;
8383
Assert-AreEqual $nonDefaultFD $aset.PlatformFaultDomainCount;
84-
Assert-False {$aset.Managed};
8584
Assert-AreEqual 'Classic' $aset.Sku;
8685
Assert-AreEqual "b" $aset.Tags["a"];
8786

88-
$job = $aset | Update-AzAvailabilitySet -Managed -AsJob;
87+
$job = $aset | Update-AzAvailabilitySet -Sku 'Aligned' -AsJob;
8988
$result = $job | Wait-Job;
9089
Assert-AreEqual "Completed" $result.State;
9190
$aset = Get-AzAvailabilitySet -ResourceGroupName $rgname -Name $asetName;

src/Compute/Compute.Test/ScenarioTests/DiskRPTests.ps1

Lines changed: 91 additions & 116 deletions
Large diffs are not rendered by default.

src/Compute/Compute.Test/ScenarioTests/GalleryTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,12 @@ public void TestGalleryCrossTenant()
3737
{
3838
TestRunner.RunTestScript("Test-GalleryCrossTenant");
3939
}
40+
41+
[Fact]
42+
[Trait(Category.AcceptanceType, Category.CheckIn)]
43+
public void GalleryImageVersion()
44+
{
45+
TestRunner.RunTestScript("Test-GalleryImageVersion");
46+
}
4047
}
4148
}

src/Compute/Compute.Test/ScenarioTests/GalleryTests.ps1

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,169 @@ function Test-GalleryCrossTenant
402402
Clean-ResourceGroup $rgname
403403
}
404404
}
405+
406+
<#
407+
.SYNOPSIS
408+
Testing gallery image version commands
409+
#>
410+
function Test-GalleryImageVersion
411+
{
412+
# Setup
413+
$rgname = Get-ComputeTestResourceName;
414+
$galleryName = 'gallery' + $rgname;
415+
$galleryImageName = 'galleryimage' + $rgname;
416+
$galleryImageVersionName = 'imageversion' + $rgname;
417+
418+
try
419+
{
420+
# Common
421+
$loc = "southcentralus";
422+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
423+
$description1 = "Original Description";
424+
425+
# Gallery
426+
New-AzGallery -ResourceGroupName $rgname -Name $galleryName -Description $description1 -Location $loc;
427+
428+
$gallery = Get-AzGallery -ResourceGroupName $rgname -Name $galleryName;
429+
Verify-Gallery $gallery $rgname $galleryName $loc $description1;
430+
$output = $gallery | Out-String;
431+
432+
# Gallery Image Definition
433+
$publisherName = "galleryPublisher20180927";
434+
$offerName = "galleryOffer20180927";
435+
$skuName = "gallerySku20180927";
436+
$eula = "eula";
437+
$privacyStatementUri = "https://www.microsoft.com";
438+
$releaseNoteUri = "https://www.microsoft.com";
439+
$disallowedDiskTypes = "Premium_LRS";
440+
$endOfLifeDate = [DateTime]::ParseExact('12 07 2025 18 02', 'HH mm yyyy dd MM', $null);
441+
$minMemory = 1;
442+
$maxMemory = 100;
443+
$minVCPU = 2;
444+
$maxVCPU = 32;
445+
$purchasePlanName = "purchasePlanName";
446+
$purchasePlanProduct = "purchasePlanProduct";
447+
$purchasePlanPublisher = "";
448+
$osState = "Generalized";
449+
$osType = "Linux";
450+
451+
New-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $galleryImageName `
452+
-Location $loc -Publisher $publisherName -Offer $offerName -Sku $skuName `
453+
-OsState $osState -OsType $osType `
454+
-Description $description1 -Eula $eula `
455+
-PrivacyStatementUri $privacyStatementUri -ReleaseNoteUri $releaseNoteUri `
456+
-DisallowedDiskType $disallowedDiskTypes -EndOfLifeDate $endOfLifeDate `
457+
-MinimumMemory $minMemory -MaximumMemory $maxMemory `
458+
-MinimumVCPU $minVCPU -MaximumVCPU $maxVCPU `
459+
-PurchasePlanName $purchasePlanName `
460+
-PurchasePlanProduct $purchasePlanProduct `
461+
-PurchasePlanPublisher $purchasePlanPublisher;
462+
463+
$definition = Get-AzGalleryImageDefinition -ResourceGroupName $rgname -GalleryName $galleryName -Name $galleryImageName;
464+
$output = $definition | Out-String;
465+
Verify-GalleryImageDefinition $definition $rgname $galleryImageName $loc $description1 `
466+
$eula $privacyStatementUri $releaseNoteUri `
467+
$osType $osState $endOfLifeDate `
468+
$publisherName $offerName $skuName `
469+
$minVCPU $maxVCPU $minMemory $maxMemory `
470+
$disallowedDiskTypes `
471+
$purchasePlanName $purchasePlanPublisher $purchasePlanProduct;
472+
473+
# Gallery Image Version
474+
$galleryImageVersionName = "1.0.0";
475+
476+
# Create a VM first
477+
$vmsize = 'Standard_A4';
478+
$vmname = 'vm' + $rgname;
479+
$p = New-AzVMConfig -VMName $vmname -VMSize $vmsize;
480+
Assert-AreEqual $p.HardwareProfile.VmSize $vmsize;
481+
482+
# NRP
483+
$subnet = New-AzVirtualNetworkSubnetConfig -Name ('subnet' + $rgname) -AddressPrefix "10.0.0.0/24";
484+
$vnet = New-AzVirtualNetwork -Force -Name ('vnet' + $rgname) -ResourceGroupName $rgname -Location $loc -AddressPrefix "10.0.0.0/16" -Subnet $subnet;
485+
$vnet = Get-AzVirtualNetwork -Name ('vnet' + $rgname) -ResourceGroupName $rgname;
486+
$subnetId = $vnet.Subnets[0].Id;
487+
$pubip = New-AzPublicIpAddress -Force -Name ('pubip' + $rgname) -ResourceGroupName $rgname -Location $loc -AllocationMethod Dynamic -DomainNameLabel ('pubip' + $rgname);
488+
$pubip = Get-AzPublicIpAddress -Name ('pubip' + $rgname) -ResourceGroupName $rgname;
489+
$nic = New-AzNetworkInterface -Force -Name ('nic' + $rgname) -ResourceGroupName $rgname -Location $loc -SubnetId $subnetId -PublicIpAddressId $pubip.Id;
490+
$nic = Get-AzNetworkInterface -Name ('nic' + $rgname) -ResourceGroupName $rgname;
491+
492+
# Adding the same Nic but not set it Primary
493+
$p = Add-AzVMNetworkInterface -VM $p -Id $nic.Id -Primary;
494+
495+
# Storage Account (SA)
496+
$stoname = 'sto' + $rgname;
497+
$stotype = 'Standard_LRS';
498+
New-AzStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype;
499+
$stoaccount = Get-AzStorageAccount -ResourceGroupName $rgname -Name $stoname;
500+
501+
$osDiskName = 'osDisk';
502+
$osDiskCaching = 'ReadWrite';
503+
$osDiskVhdUri = "https://$stoname.blob.core.windows.net/test/os.vhd";
504+
$dataDiskVhdUri1 = "https://$stoname.blob.core.windows.net/test/data1.vhd";
505+
$dataDiskVhdUri2 = "https://$stoname.blob.core.windows.net/test/data2.vhd";
506+
507+
$p = Set-AzVMOSDisk -VM $p -Name $osDiskName -VhdUri $osDiskVhdUri -Caching $osDiskCaching -CreateOption FromImage;
508+
509+
$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk1' -Caching 'ReadOnly' -DiskSizeInGB 10 -Lun 1 -VhdUri $dataDiskVhdUri1 -CreateOption Empty;
510+
$p = Add-AzVMDataDisk -VM $p -Name 'testDataDisk2' -Caching 'ReadOnly' -DiskSizeInGB 11 -Lun 2 -VhdUri $dataDiskVhdUri2 -CreateOption Empty;
511+
512+
# OS & Image
513+
$user = "Foo12";
514+
$password = $PLACEHOLDER;
515+
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
516+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
517+
$computerName = 'test';
518+
$vhdContainer = "https://$stoname.blob.core.windows.net/test";
519+
520+
# $p.StorageProfile.OSDisk = $null;
521+
$p = Set-AzVMOperatingSystem -VM $p -Windows -ComputerName $computerName -Credential $cred;
522+
523+
$imgRef = Get-DefaultCRPImage -loc $loc;
524+
$p = ($imgRef | Set-AzVMSourceImage -VM $p);
525+
526+
# Virtual Machine
527+
New-AzVM -ResourceGroupName $rgname -Location $loc -VM $p;
528+
529+
# Create Image using the VM's OS disk and data disks.
530+
$imageName = 'image' + $rgname;
531+
$imageConfig = New-AzImageConfig -Location $loc;
532+
Set-AzImageOsDisk -Image $imageConfig -OsType 'Windows' -OsState 'Generalized' -BlobUri $osDiskVhdUri;
533+
$imageConfig = Add-AzImageDataDisk -Image $imageConfig -Lun 1 -BlobUri $dataDiskVhdUri1;
534+
$imageConfig = Add-AzImageDataDisk -Image $imageConfig -Lun 2 -BlobUri $dataDiskVhdUri2;
535+
536+
$image = New-AzImage -Image $imageConfig -ImageName $imageName -ResourceGroupName $rgname
537+
$targetRegions = @(@{Name='South Central US';ReplicaCount=1;StorageAccountType='Standard_LRS'},@{Name='East US';ReplicaCount=2},@{Name='Central US'});
538+
$tag = @{test1 = "testval1"; test2 = "testval2" };
539+
540+
New-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
541+
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName `
542+
-Location $loc -SourceImageId $image.Id -ReplicaCount 1 `
543+
-PublishingProfileEndOfLifeDate $endOfLifeDate `
544+
-StorageAccountType Standard_LRS `
545+
-TargetRegion $targetRegions;
546+
547+
$version = Get-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
548+
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName;
549+
Verify-GalleryImageVersion $version $rgname $galleryImageVersionName $loc `
550+
$image.Id 1 $endOfLifeDate $targetRegions;
551+
552+
Update-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
553+
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName `
554+
-Tag $tag;
555+
556+
$version = Get-AzGalleryImageVersion -ResourceGroupName $rgname -GalleryName $galleryName `
557+
-GalleryImageDefinitionName $galleryImageName -Name $galleryImageVersionName;
558+
Verify-GalleryImageVersion $version $rgname $galleryImageVersionName $loc `
559+
$image.Id 1 $endOfLifeDate $targetRegions;
560+
561+
$version | Remove-AzGalleryImageVersion -Force;
562+
$definition | Remove-AzGalleryImageDefinition -Force;
563+
$gallery | Remove-AzGallery -Force;
564+
}
565+
finally
566+
{
567+
# Cleanup
568+
Clean-ResourceGroup $rgname
569+
}
570+
}

src/Compute/Compute.Test/ScenarioTests/LogAnalyticTests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ function Test-ExportLogAnalyticThrottledRequestsNegative
2323
$to = Get-Date -Year 2018 -Month 2 -Day 28 -Hour 9;
2424
$sasuri = 'https://fakestore.blob.core.windows.net/mylogs/fakesas';
2525
Assert-ThrowsContains { `
26-
$result = Export-AzLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByResourceName;} `
26+
$result = Export-AzLogAnalyticThrottledRequest -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByResourceName;} `
2727
"the given SAS URI";
2828
}
2929

@@ -79,7 +79,7 @@ function Test-ExportLogAnalytics
7979
Assert-True { $output.Contains(".csv"); }
8080
Assert-True { $output.Contains("RequestRateByInterval"); }
8181

82-
$result = Export-AzLogAnalyticThrottledRequests -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
82+
$result = Export-AzLogAnalyticThrottledRequest -Location $loc -FromTime $from -ToTime $to -BlobContainerSasUri $sasuri -GroupByThrottlePolicy -GroupByOperationName -GroupByResourceName;
8383
Assert-AreEqual "Succeeded" $result.Status;
8484
$output = $result | Out-String;
8585
Assert-True { $output.Contains(".csv"); }

src/Compute/Compute.Test/ScenarioTests/NewVhdVMTests.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,8 @@ public NewVhdVMTests(Xunit.Abstractions.ITestOutputHelper output)
2424
{
2525
}
2626

27-
#if NETSTANDARD
28-
[Fact(Skip = "Resources -> ResourceManager, needs re-recorded")]
27+
[Fact]
2928
[Trait(Category.RunType, Category.DesktopOnly)]
30-
#else
31-
[Fact(Skip = "Resources -> ResourceManager, needs re-recorded")]
32-
#endif
3329
[Trait(Category.AcceptanceType, Category.CheckIn)]
3430
public void TestWithValidVhdDiskFile()
3531
{
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.WindowsAzure.Commands.ScenarioTest;
16+
using Xunit;
17+
18+
namespace Microsoft.Azure.Commands.Compute.Test.ScenarioTests
19+
{
20+
public class PPGTests : ComputeTestRunner
21+
{
22+
public PPGTests(Xunit.Abstractions.ITestOutputHelper output)
23+
: base(output)
24+
25+
{
26+
}
27+
28+
[Fact]
29+
[Trait(Category.AcceptanceType, Category.CheckIn)]
30+
public void TestPPG()
31+
{
32+
TestRunner.RunTestScript("Test-ProximityPlacementGroup");
33+
}
34+
35+
[Fact]
36+
[Trait(Category.AcceptanceType, Category.CheckIn)]
37+
public void TestPPGAvSet()
38+
{
39+
TestRunner.RunTestScript("Test-ProximityPlacementGroupAvSet");
40+
}
41+
42+
[Fact]
43+
[Trait(Category.AcceptanceType, Category.CheckIn)]
44+
public void TestPPGVM()
45+
{
46+
TestRunner.RunTestScript("Test-ProximityPlacementGroupVM");
47+
}
48+
}
49+
}

0 commit comments

Comments
 (0)