Skip to content

Commit 3413229

Browse files
New-AzVM | Make PublicIpSku Standard by default (#26619)
* New-AzVM | Make PublicIpSku Standard by default * update changeLog.md * update help doc * Update TestVMWithPublicIPAddressStandardSku.json --------- Co-authored-by: Vincent Dai <[email protected]>
1 parent 751c4a8 commit 3413229

File tree

6 files changed

+3038
-3
lines changed

6 files changed

+3038
-3
lines changed

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,13 @@ public void TestVMNoPublicIPAddress()
473473
TestRunner.RunTestScript("Test-VMNoPublicIPAddress");
474474
}
475475

476+
[Fact]
477+
[Trait(Category.AcceptanceType, Category.CheckIn)]
478+
public void TestVMWithPublicIPAddressStandardSku()
479+
{
480+
TestRunner.RunTestScript("Test-VMWithPublicIPAddressStandardSku");
481+
}
482+
476483
[Fact]
477484
[Trait(Category.AcceptanceType, Category.CheckIn)]
478485
public void TestVMForceDelete()

src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5628,6 +5628,46 @@ function Test-VMNoPublicIPAddress
56285628
}
56295629
}
56305630

5631+
<#
5632+
.SYNOPSIS
5633+
Test Virtual Machine creation process with a Public IP Address when it is
5634+
provided as a parameter.
5635+
When PublicIpSku is not specified, it should be Standard Sku by default
5636+
(Since Az 13.0.0 and Az.Compute 9.0.0).
5637+
#>
5638+
function Test-VMWithPublicIPAddressStandardSku
5639+
{
5640+
# Setup
5641+
$rgname = Get-ComputeTestResourceName;
5642+
$loc = Get-ComputeVMLocation;
5643+
5644+
try
5645+
{
5646+
$pipName = "test-pip-standard";
5647+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
5648+
5649+
# VM Profile & Hardware
5650+
$vmname = 'v' + $rgname;
5651+
$domainNameLabel = "d1" + $rgname;
5652+
5653+
# Creating a VM using simple parameter set
5654+
$securePassword = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force;
5655+
$user = "admin01";
5656+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
5657+
5658+
$vm = New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel -PublicIPAddressName $pipName;
5659+
5660+
# Check that no PublicIPAddress resource was created.
5661+
$publicIPAddress = Get-AzPublicIpAddress -ResourceGroupName $rgname -Name $pipName;
5662+
Assert-AreEqual $publicIPAddress.Sku.Name "Standard";
5663+
}
5664+
finally
5665+
{
5666+
# Cleanup
5667+
Clean-ResourceGroup $rgname;
5668+
}
5669+
}
5670+
56315671
<#
56325672
.SYNOPSIS
56335673
Test Virtual Machine Force Delete

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineTests/TestVMWithPublicIPAddressStandardSku.json

Lines changed: 2986 additions & 0 deletions
Large diffs are not rendered by default.

src/Compute/Compute/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
2121
-->
2222
## Upcoming Release
23+
* Made `-PublicIpSku` parameter Standard by default in `New-AzVM`
2324

2425
## Version 8.5.0
2526
* Added optional parameters `-SecurityPostureId` and `-SecurityPostureExcludeExtension` to cmdlets `New-AzVmss` and `New-AzVmssConfig`.

src/Compute/Compute/VirtualMachine/Operation/NewAzureVMCommand.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959

6060
namespace Microsoft.Azure.Commands.Compute
6161
{
62-
[GenericBreakingChangeWithVersion("The default publicIpSku will be changed from Basic to Standard. This change is expected to take effect in the next version. If publicIpSku is not specified, default will be switched to Standard. For more information refer to https://aka.ms/ipbasictostandard.", "13.0.0", "9.0.0")]
6362
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VM", SupportsShouldProcess = true, DefaultParameterSetName = "SimpleParameterSet")]
6463
[OutputType(typeof(PSAzureOperationResponse), typeof(PSVirtualMachine))]
6564
public class NewAzureVMCommand : VirtualMachineBaseCmdlet
@@ -587,7 +586,9 @@ public async Task<ResourceConfig<VirtualMachine>> CreateConfigAsync()
587586
publicIpSku = _cmdlet.PublicIpSku == "Basic" ? PublicIPAddressStrategy.Sku.Basic : PublicIPAddressStrategy.Sku.Standard;
588587
}
589588
else {
590-
publicIpSku = _cmdlet.Zone == null ? PublicIPAddressStrategy.Sku.Basic : PublicIPAddressStrategy.Sku.Standard;
589+
// since Az 13.0.0 and Az.Compute 9.0.0, if PublicIpSku is not specified, it should be Standard by default.
590+
// https://aka.ms/ipbasictostandard
591+
publicIpSku = PublicIPAddressStrategy.Sku.Standard;
591592
}
592593

593594
if (_cmdlet.IsParameterBound(c => c.SecurityType))

src/Compute/Compute/help/New-AzVM.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,7 @@ Aliases:
10111011

10121012
Required: False
10131013
Position: Named
1014-
Default value: None
1014+
Default value: Standard
10151015
Accept pipeline input: False
10161016
Accept wildcard characters: False
10171017
```

0 commit comments

Comments
 (0)