Skip to content

Commit 2e210a4

Browse files
SandidoBethanyZhou
andauthored
Change default Size value in New-AzVM to Standard_D2S_v3 (Azure#14622)
* dev, test, changelog, help doc. * help doc clean * Update NewAzureVMCommand.cs * update recorded test * attempting to resolve errors. Recording then immediately playing back fails. * test passes Co-authored-by: Beisi Zhou <[email protected]>
1 parent 7f9d14e commit 2e210a4

File tree

6 files changed

+2801
-23
lines changed

6 files changed

+2801
-23
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,5 +374,12 @@ public void TestVirtualMachinePatchAPI()
374374
{
375375
TestRunner.RunTestScript("Test-VirtualMachinePatchAPI");
376376
}
377+
378+
[Fact]
379+
[Trait(Category.AcceptanceType, Category.CheckIn)]
380+
public void TestNewAzVMDefaultingSize()
381+
{
382+
TestRunner.RunTestScript("Test-NewAzVMDefaultingSize");
383+
}
377384
}
378385
}

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4617,4 +4617,40 @@ function Test-VirtualMachinePatchAPI
46174617
# Cleanup
46184618
Clean-ResourceGroup $rgname
46194619
}
4620+
}
4621+
4622+
<#
4623+
.SYNOPSIS
4624+
Create VM using New-AzVM non-Default parameter set to test the hardcoded default VM size Standard_D2s_v3.
4625+
#>
4626+
function Test-NewAzVMDefaultingSize
4627+
{
4628+
# Setup
4629+
$rgname = Get-ComputeTestResourceName;
4630+
$loc = "eastus";#Get-ComputeVMLocation;
4631+
4632+
try
4633+
{
4634+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
4635+
4636+
# VM Profile & Hardware
4637+
$vmname = 'v' + $rgname;
4638+
$defaultSize = "Standard_D2s_v3";
4639+
$domainNameLabel = "d1" + $rgname;
4640+
4641+
# Creating a VM using simple parameter set
4642+
$securePassword = Get-PasswordForVM | ConvertTo-SecureString -AsPlainText -Force;
4643+
$user = "admin01";
4644+
$cred = New-Object System.Management.Automation.PSCredential ($user, $securePassword);
4645+
$vm = New-AzVM -ResourceGroupName $rgname -Name $vmname -Credential $cred -DomainNameLabel $domainNameLabel;
4646+
4647+
Assert-NotNull $vm;
4648+
Assert-AreEqual $vm.HardwareProfile.Vmsize $defaultSize;
4649+
4650+
}
4651+
finally
4652+
{
4653+
# Cleanup
4654+
Clean-ResourceGroup $rgname;
4655+
}
46204656
}

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

Lines changed: 2728 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
@@ -26,6 +26,7 @@
2626
- `Set-AzVmUefi`
2727
- `Set-AzVmssSecurityProfile`
2828
- `Set-AzVmssUefi`
29+
* Edited default value for Size parameter in New-AzVM cmdlet from Standard_DS1_v2 to Standard_D2s_v3.
2930

3031
## Version 4.10.0
3132
* Added parameter `-EnableHotpatching` to the `Set-AzVMOperatingSystem` cmdlet for Windows machines.

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public class NewAzureVMCommand : VirtualMachineBaseCmdlet
199199

200200
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
201201
[Parameter(ParameterSetName = DiskFileParameterSet, Mandatory = false)]
202-
public string Size { get; set; } = "Standard_DS1_v2";
202+
public string Size { get; set; } = "Standard_D2s_v3";
203203

204204
[Parameter(ParameterSetName = SimpleParameterSet, Mandatory = false)]
205205
[Parameter(ParameterSetName = DiskFileParameterSet, Mandatory = false)]
@@ -458,6 +458,11 @@ async Task StrategyExecuteCmdletAsync(IAsyncCmdlet asyncCmdlet)
458458

459459
var parameters = new Parameters(this, client, resourceClient);
460460

461+
// Information message if the default Size value is used.
462+
if (!this.IsBound(Size))
463+
{
464+
WriteInformation("No Size value has been provided. The VM will be created with the default size Standard_D2s_v3.", new string[] { "PSHOST" });
465+
}
461466

462467
if (DiskFile != null)
463468
{

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

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ New-AzVM [[-ResourceGroupName] <String>] [[-Location] <String>] [[-Zone] <String
2121
[-AllocationMethod <String>] [-SecurityGroupName <String>] [-OpenPorts <Int32[]>] [-Image <String>]
2222
[-Size <String>] [-AvailabilitySetName <String>] [-SystemAssignedIdentity] [-UserAssignedIdentity <String>]
2323
[-AsJob] [-DataDiskSizeInGb <Int32[]>] [-EnableUltraSSD] [-ProximityPlacementGroupId <String>]
24-
[-HostId <String>] [-VmssId <String>] [-Priority <String>] [-EvictionPolicy <String>] [-MaxPrice <Double>] [-EncryptionAtHost]
25-
[-HostGroupId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
24+
[-HostId <String>] [-VmssId <String>] [-Priority <String>] [-EvictionPolicy <String>] [-MaxPrice <Double>]
25+
[-EncryptionAtHost] [-HostGroupId <String>] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
26+
[<CommonParameters>]
2627
```
2728

2829
### DefaultParameterSet
@@ -334,6 +335,23 @@ Accept pipeline input: False
334335
Accept wildcard characters: False
335336
```
336337

338+
### -EncryptionAtHost
339+
EncryptionAtHost property can be used by user in the request to enable or disable the Host Encryption for the virtual machine or virtual machine scale set.
340+
This will enable the encryption for all the disks including Resource/Temp disk at host itself.
341+
Default: The Encryption at host will be disabled unless this property is set to true for the resource.
342+
343+
```yaml
344+
Type: System.Management.Automation.SwitchParameter
345+
Parameter Sets: SimpleParameterSet, DiskFileParameterSet
346+
Aliases:
347+
348+
Required: False
349+
Position: Named
350+
Default value: False
351+
Accept pipeline input: False
352+
Accept wildcard characters: False
353+
```
354+
337355
### -EvictionPolicy
338356
The eviction policy for the Azure Spot virtual machine. Supported values are 'Deallocate' and 'Delete'.
339357

@@ -472,24 +490,6 @@ Accept pipeline input: False
472490
Accept wildcard characters: False
473491
```
474492

475-
### -EncryptionAtHost
476-
EncryptionAtHost property can be used by user in the request to enable or disable the Host Encryption for the virtual machine or virtual machine scale set.
477-
This will enable the encryption for all the disks including Resource/Temp disk at host itself.
478-
Default: The Encryption at host will be disabled unless this property is set to true for the resource.
479-
480-
```yaml
481-
Type: System.Management.Automation.SwitchParameter
482-
Parameter Sets: SimpleParameterSet, DiskParameterSet
483-
Aliases:
484-
485-
Required: False
486-
Position: Named
487-
Default value: False
488-
Accept pipeline input: False
489-
Accept wildcard characters: False
490-
```
491-
492-
493493
### -Name
494494
The name of the VM resource.
495495

@@ -611,7 +611,7 @@ Accept wildcard characters: False
611611
```
612612

613613
### -Size
614-
The Virtual Machine Size. The Default Value is: Standard_DS1_v2.
614+
The Virtual Machine Size. The Default Value is: Standard_D2s_v3.
615615

616616
```yaml
617617
Type: System.String
@@ -620,7 +620,7 @@ Aliases:
620620
621621
Required: False
622622
Position: Named
623-
Default value: Standard_DS1_v2
623+
Default value: Standard_D2s_v3
624624
Accept pipeline input: False
625625
Accept wildcard characters: False
626626
```
@@ -741,6 +741,7 @@ The ID of Virtual Machine Scale Set that this VM will be associated with
741741
Type: System.String
742742
Parameter Sets: SimpleParameterSet, DiskFileParameterSet
743743
Aliases:
744+
744745
Required: False
745746
Position: Named
746747
Default value: None

0 commit comments

Comments
 (0)