Skip to content

Commit

Permalink
New-AzVM | Make PublicIpSku Standard by default (Azure#26619)
Browse files Browse the repository at this point in the history
* New-AzVM | Make PublicIpSku Standard by default

* update changeLog.md

* update help doc

* Update TestVMWithPublicIPAddressStandardSku.json

---------

Co-authored-by: Vincent Dai <[email protected]>
  • Loading branch information
phrazfipho and vidai-msft authored Nov 7, 2024
1 parent 751c4a8 commit 3413229
Show file tree
Hide file tree
Showing 6 changed files with 3,038 additions and 3 deletions.
7 changes: 7 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,13 @@ public void TestVMNoPublicIPAddress()
TestRunner.RunTestScript("Test-VMNoPublicIPAddress");
}

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

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestVMForceDelete()
Expand Down
40 changes: 40 additions & 0 deletions src/Compute/Compute.Test/ScenarioTests/VirtualMachineTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5628,6 +5628,46 @@ function Test-VMNoPublicIPAddress
}
}

<#
.SYNOPSIS
Test Virtual Machine creation process with a Public IP Address when it is
provided as a parameter.
When PublicIpSku is not specified, it should be Standard Sku by default
(Since Az 13.0.0 and Az.Compute 9.0.0).
#>
function Test-VMWithPublicIPAddressStandardSku
{
# Setup
$rgname = Get-ComputeTestResourceName;
$loc = Get-ComputeVMLocation;

try
{
$pipName = "test-pip-standard";
New-AzResourceGroup -Name $rgname -Location $loc -Force;

# VM Profile & Hardware
$vmname = 'v' + $rgname;
$domainNameLabel = "d1" + $rgname;

# Creating a VM using simple parameter set
$securePassword = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force;
$user = "admin01";
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);

$vm = New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel -PublicIPAddressName $pipName;

# Check that no PublicIPAddress resource was created.
$publicIPAddress = Get-AzPublicIpAddress -ResourceGroupName $rgname -Name $pipName;
Assert-AreEqual $publicIPAddress.Sku.Name "Standard";
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname;
}
}

<#
.SYNOPSIS
Test Virtual Machine Force Delete
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Compute/Compute/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
-->
## Upcoming Release
* Made `-PublicIpSku` parameter Standard by default in `New-AzVM`

## Version 8.5.0
* Added optional parameters `-SecurityPostureId` and `-SecurityPostureExcludeExtension` to cmdlets `New-AzVmss` and `New-AzVmssConfig`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@

namespace Microsoft.Azure.Commands.Compute
{
[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")]
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VM", SupportsShouldProcess = true, DefaultParameterSetName = "SimpleParameterSet")]
[OutputType(typeof(PSAzureOperationResponse), typeof(PSVirtualMachine))]
public class NewAzureVMCommand : VirtualMachineBaseCmdlet
Expand Down Expand Up @@ -587,7 +586,9 @@ public async Task<ResourceConfig<VirtualMachine>> CreateConfigAsync()
publicIpSku = _cmdlet.PublicIpSku == "Basic" ? PublicIPAddressStrategy.Sku.Basic : PublicIPAddressStrategy.Sku.Standard;
}
else {
publicIpSku = _cmdlet.Zone == null ? PublicIPAddressStrategy.Sku.Basic : PublicIPAddressStrategy.Sku.Standard;
// since Az 13.0.0 and Az.Compute 9.0.0, if PublicIpSku is not specified, it should be Standard by default.
// https://aka.ms/ipbasictostandard
publicIpSku = PublicIPAddressStrategy.Sku.Standard;
}

if (_cmdlet.IsParameterBound(c => c.SecurityType))
Expand Down
2 changes: 1 addition & 1 deletion src/Compute/Compute/help/New-AzVM.md
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,7 @@ Aliases:

Required: False
Position: Named
Default value: None
Default value: Standard
Accept pipeline input: False
Accept wildcard characters: False
```
Expand Down

0 comments on commit 3413229

Please sign in to comment.