Skip to content

Commit 50b9d53

Browse files
grizzlytheodoreTheodore ChangVeryEarly
authored
Update default VMSS creation to OrchestrationMode: Flexible (#23146)
* Vmss defaulting to Flex mode changes * remove natpool setting to null for flex mode * change log * add test for defaulting to flexible orchestration mode * switch parameter, better checking * add example * Update New-AzVmss.md fix static analysis in examples * update test to work with updated trusted launch default --------- Co-authored-by: Theodore Chang <[email protected]> Co-authored-by: Yabo Hu <[email protected]>
1 parent 297fa4f commit 50b9d53

File tree

7 files changed

+901
-71
lines changed

7 files changed

+901
-71
lines changed

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,13 @@ public void TestVirtualMachineScaleSetSecurityTypeUpdate()
374374
{
375375
TestRunner.RunTestScript("Test-VirtualMachineScaleSetSecurityTypeUpdate");
376376
}
377+
378+
[Fact]
379+
[Trait(Category.AcceptanceType, Category.CheckIn)]
380+
public void TestVirtualMachineScaleSetDefaultToFlexibleOrchestrationMode()
381+
{
382+
TestRunner.RunTestScript("Test-VirtualMachineScaleSetDefaultToFlexibleOrchestrationMode");
383+
}
377384

378385
[Fact]
379386
[Trait(Category.AcceptanceType, Category.CheckIn)]

src/Compute/Compute.Test/ScenarioTests/VirtualMachineScaleSetTests.ps1

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5121,6 +5121,39 @@ function Test-VirtualMachineScaleSetSecurityTypeDefaultingFromImage
51215121
}
51225122
}
51235123

5124+
<#
5125+
.SYNOPSIS
5126+
Test Virtual Machine Scale Set defaulting to OrchestrationMode: Flexible when property is not provided.
5127+
#>
5128+
function Test-VirtualMachineScaleSetDefaultToFlexibleOrchestrationMode
5129+
{
5130+
# Setup
5131+
$rgname = Get-ComputeTestResourceName;
5132+
$loc = Get-ComputeVMLocation;
5133+
5134+
try
5135+
{
5136+
# Common
5137+
New-AzResourceGroup -Name $rgname -Location $loc -Force;
5138+
5139+
# New VMSS Parameters
5140+
$vmssName1 = 'vmss1' + $rgname;
5141+
5142+
$vmssConfig = New-AzVmssConfig -Location $loc -UpgradePolicyMode 'Manual' -SinglePlacementGroup $true -securitytype standard
5143+
$vmss = New-AzVmss -ResourceGroupName $rgname -VMScaleSetName $vmssName1 -VirtualMachineScaleSet $vmssConfig
5144+
5145+
# Asserts
5146+
# check flexmode
5147+
Assert-AreEqual $vmss.OrchestrationMode "Flexible"
5148+
# check SinglePlacementGroup
5149+
Assert-AreEqual $vmss.SinglePlacementGroup $true
5150+
}
5151+
finally
5152+
{
5153+
# Cleanup
5154+
Clean-ResourceGroup $rgname;
5155+
}
5156+
}
51245157

51255158
<#
51265159
.SYNOPSIS
@@ -5176,4 +5209,4 @@ function Test-VirtualMachineScaleSetAttachAndDetach
51765209
# Cleanup
51775210
Clean-ResourceGroup $rgname
51785211
}
5179-
}
5212+
}

src/Compute/Compute.Test/SessionRecords/Microsoft.Azure.Commands.Compute.Test.ScenarioTests.VirtualMachineScaleSetTests/TestVirtualMachineScaleSetDefaultToFlexibleOrchestrationMode.json

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

src/Compute/Compute/ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
* Added update functionality in `Update-AzVmss` for parameters `SecurityType`, `EnableSecureBoot`, and `EnableVtpm` for the parameter set with the Put operation.
2424
* Upgraded Azure.Core to 1.35.0.
2525
* [Breaking change] Removed unversioned and outdated linux image aliases of `CentOS`, `RHEL`, `UbuntuLTS` and `Debian`.
26+
* [Breaking change] `New-AzVmss` will default to `OrchestrationMode` set as `Flexible` if it is not set as `Uniform` explicitly.
27+
* `New-AzVmss` can now create VMSS with `OrchestrationMode` set to `Flexible` using `-SinglePlacementGroup` and `-UpgradePolicy`.
28+
* Removed unversioned and outdated images from New-AzVmss `-ImageName` argument completers.
2629
* [Breaking Change] Added defaulting logic for VM and VMSS creation to set SecurityType to TrustedLaunch and SecureBootEnabled and VTpmEnalbed to true when those are not set by the user.
2730
* [Breaking Change] Added defaulting logic for Disk creation to default to TrustedLaunch when able. Allows the user to turn this off by setting the SecurityType to Standard.
2831
* Added new parameters `-ElasticSanResourceId` and `-OptimizedForFrequentAttach` to `New-AzDiskConfig` cmdlet.

src/Compute/Compute/Generated/VirtualMachineScaleSet/VirtualMachineScaleSetCreateOrUpdateMethod.cs

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
namespace Microsoft.Azure.Commands.Compute.Automation
4242
{
4343
[GenericBreakingChangeWithVersion("Starting November 2023, the \"New-AzVmss\" cmdlet will default to Trusted Launch VMSS. For more info, visit https://aka.ms/TLaD.", "11.0.0", "7.0.0")]
44-
[GenericBreakingChangeWithVersion("Starting November 2023, the \"New-AzVmss\" cmdlet will use new defaults: Flexible orchestration mode and enable NATv2 configuration for Load Balancer. To learn more about Flexible Orchestration modes, visit https://aka.ms/orchestrationModeVMSS.", "11.0.0", "7.0.0")]
44+
4545
[Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "Vmss", DefaultParameterSetName = "DefaultParameter", SupportsShouldProcess = true)]
4646
[OutputType(typeof(PSVirtualMachineScaleSet))]
4747
public partial class NewAzureRmVmss : ComputeAutomationBaseCmdlet
@@ -109,23 +109,10 @@ public override void ExecuteCmdlet()
109109
"Consider using \"latest\" as the image version. This allows VMSS to auto upgrade when a newer version is available.");
110110
}
111111

112-
if (parameters?.OrchestrationMode == "Flexible")
113-
{
114-
if (parameters?.VirtualMachineProfile?.NetworkProfile?.NetworkInterfaceConfigurations != null)
115-
{
116-
foreach (var nicConfig in parameters.VirtualMachineProfile.NetworkProfile.NetworkInterfaceConfigurations)
117-
{
118-
if (nicConfig.IpConfigurations != null)
119-
{
120-
foreach (var ipConfig in nicConfig.IpConfigurations)
121-
{
122-
ipConfig.LoadBalancerInboundNatPools = null;
123-
}
124-
}
125-
}
126-
}
112+
if (parameters.OrchestrationMode == null) { parameters.OrchestrationMode = flexibleOrchestrationMode; }
127113

128-
parameters.UpgradePolicy = null;
114+
if (parameters?.OrchestrationMode == flexibleOrchestrationMode)
115+
{
129116

130117
flexibleOrchestrationModeDefaultParameters(parameters);
131118
checkFlexibleOrchestrationModeParamsDefaultParamSet(parameters);
@@ -463,19 +450,11 @@ private bool shouldGuestAttestationExtBeInstalled(VirtualMachineScaleSet vmssPar
463450
/// There is some concern with the above behavior being correct or not, and requires additional testing before changing.
464451
private void checkFlexibleOrchestrationModeParamsDefaultParamSet(VirtualMachineScaleSet parameters)
465452
{
466-
if (parameters?.UpgradePolicy != null)
467-
{
468-
throw new Exception("UpgradePolicy is not currently supported for a VMSS with OrchestrationMode set to Flexible.");
469-
}
470-
else if (parameters?.VirtualMachineProfile?.NetworkProfile?.NetworkApiVersion != null
453+
if (parameters?.VirtualMachineProfile?.NetworkProfile?.NetworkApiVersion != null
471454
&& convertAPIVersionToInt(parameters?.VirtualMachineProfile?.NetworkProfile?.NetworkApiVersion) < vmssFlexibleOrchestrationModeNetworkAPIVersionMinimumInt)
472455
{
473456
throw new Exception("The value for NetworkApiVersion is not valid for a VMSS with OrchestrationMode set to Flexible. You must use a valid Network API Version equal to or greater than " + vmssFlexibleOrchestrationModeNetworkAPIVersionMinimum);
474457
}
475-
//else if (convertAPIVersionToInt(parameters?.VirtualMachineProfile?.NetworkProfile?.NetworkApiVersion) < vmssFlexibleOrchestrationModeNetworkAPIVersionMinimumInt)
476-
//{
477-
// throw new Exception("The value for NetworkApiVersion is not valid for a VMSS with OrchestrationMode set to Flexible. You must use a valid Network API Version equal to or greater than " + vmssFlexibleOrchestrationModeNetworkAPIVersionMinimum);
478-
//}
479458
}
480459

481460
private void flexibleOrchestrationModeDefaultParameters(VirtualMachineScaleSet parameters)
@@ -485,10 +464,7 @@ private void flexibleOrchestrationModeDefaultParameters(VirtualMachineScaleSet p
485464
{
486465
parameters.VirtualMachineProfile.NetworkProfile.NetworkApiVersion = vmssFlexibleOrchestrationModeNetworkAPIVersionMinimum;
487466
}
488-
/*if (parameters?.VirtualMachineProfile?.NetworkProfile?.NetworkApiVersion == null)
489-
{
490-
parameters.VirtualMachineProfile.NetworkProfile.NetworkApiVersion = vmssFlexibleOrchestrationModeNetworkAPIVersionMinimum;
491-
}*/
467+
492468
if (parameters?.PlatformFaultDomainCount == null)
493469
{
494470
parameters.PlatformFaultDomainCount = 1;

src/Compute/Compute/Manual/VirtualMachineScaleSetCreateOrUpdateMethod.cs

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,18 @@ public string Location
279279
public ImageAndOsType ImageAndOsType { get; set; }
280280

281281
public string DefaultLocation => "eastus";
282-
282+
283283
public async Task<ResourceConfig<VirtualMachineScaleSet>> CreateConfigAsync()
284284
{
285-
if (_cmdlet.OrchestrationMode != null)
285+
if (_cmdlet.OrchestrationMode == uniformOrchestrationMode)
286286
{
287-
return await SimpleParameterSetOrchestrationMode();
287+
return await SimpleParameterSetNormalMode();
288288
}
289289
else
290290
{
291-
return await SimpleParameterSetNormalMode();
291+
return await SimpleParameterSetOrchestrationModeFlexible();
292292
}
293293
}
294-
295294
private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetNormalMode()
296295
{
297296
ImageAndOsType = await _client.UpdateImageAndOsTypeAsync(
@@ -467,32 +466,9 @@ private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetNor
467466
);
468467
}
469468

470-
private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetOrchestrationMode()
471-
{
472-
switch (_cmdlet.OrchestrationMode)
473-
{
474-
case flexibleOrchestrationMode:
475-
return await SimpleParameterSetOrchestrationModeFlexible();
476-
default:
477-
// When the OrchestrationMode is set but it is Uniform, which represents the current behavior.
478-
return await SimpleParameterSetNormalMode();
479-
}
480-
}
481-
482469
private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetOrchestrationModeFlexible()
483470
{
484-
//check omode params and throw error otherwise
485-
checkFlexibleOrchestrationModeParams();
486471
int platformFaultDomainCountFlexibleDefault = 1;
487-
SwitchParameter singlePlacementGroupFlexibleDefault = false;
488-
489-
// Temporary message until after the Ignite 2023 release that should remove these outdated image aliases.
490-
if ((_cmdlet.ImageName == "CentOS" || _cmdlet.ImageName == "Debian" || _cmdlet.ImageName == "RHEL"
491-
|| _cmdlet.ImageName == "UbuntuLTS"))
492-
{
493-
string ImageOutdatedMessage = "You are using the image " + _cmdlet.ImageName + ", which is outdated and this image name will be removed in October 2023. Please update to a newer versioned image alias as seen here, [Find and use Azure Marketplace VM images with Azure PowerShell](https://learn.microsoft.com/en-us/azure/virtual-machines/windows/cli-ps-findimage#default-images).";
494-
_cmdlet.WriteInformation(ImageOutdatedMessage, new string[] { "PSHOST" });
495-
}
496472

497473
ImageAndOsType = await _client.UpdateImageAndOsTypeAsync(
498474
ImageAndOsType, _cmdlet.ResourceGroupName, _cmdlet.ImageName, Location);
@@ -595,7 +571,7 @@ private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetOrc
595571
zones: _cmdlet.Zone,
596572
ultraSSDEnabled: _cmdlet.EnableUltraSSD.IsPresent,
597573
identity: _cmdlet.GetVmssIdentityFromArgs(),
598-
singlePlacementGroup: singlePlacementGroupFlexibleDefault,
574+
singlePlacementGroup: _cmdlet.SinglePlacementGroup == true,
599575
proximityPlacementGroup: proximityPlacementGroup,
600576
hostGroup: hostGroup,
601577
priority: _cmdlet.Priority,
@@ -604,23 +580,15 @@ private async Task<ResourceConfig<VirtualMachineScaleSet>> SimpleParameterSetOrc
604580
scaleInPolicy: _cmdlet.ScaleInPolicy,
605581
doNotRunExtensionsOnOverprovisionedVMs: _cmdlet.SkipExtensionsOnOverprovisionedVMs.IsPresent,
606582
encryptionAtHost: _cmdlet.EncryptionAtHost.IsPresent,
607-
platformFaultDomainCount: platformFaultDomainCountFlexibleDefault,
583+
platformFaultDomainCount: _cmdlet.IsParameterBound(c => c.PlatformFaultDomainCount) ? _cmdlet.PlatformFaultDomainCount : platformFaultDomainCountFlexibleDefault,
608584
edgeZone: _cmdlet.EdgeZone,
609-
orchestrationMode: _cmdlet.IsParameterBound(c => c.OrchestrationMode) ? _cmdlet.OrchestrationMode : null,
585+
orchestrationMode: flexibleOrchestrationMode,
610586
capacityReservationId: _cmdlet.IsParameterBound(c => c.CapacityReservationGroupId) ? _cmdlet.CapacityReservationGroupId : null,
611587
securityType: _cmdlet.SecurityType,
612588
enableVtpm: _cmdlet.EnableVtpm,
613589
enableSecureBoot: _cmdlet.EnableSecureBoot
614590
);
615591
}
616-
617-
private void checkFlexibleOrchestrationModeParams()
618-
{
619-
if (_cmdlet.IsParameterBound(c => c.UpgradePolicyMode))
620-
{
621-
throw new Exception("UpgradePolicy is not currently supported for a VMSS with OrchestrationMode set to Flexible.");
622-
}
623-
}
624592
}
625593

626594
async Task SimpleParameterSetExecuteCmdlet(IAsyncCmdlet asyncCmdlet)

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

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ Create a VMSS with the TrustedLaunch security type and the necessary UEFISetting
262262
```powershell
263263
$rgname = "rganme";
264264
$loc = "eastus";
265-
New-AzResourceGroup -Name $rgname -Location $loc -Force;
266265
267266
# VMSS Profile & Hardware requirements for the TrustedLaunch default behavior.
268267
$vmssSize = 'Standard_D4s_v3';
@@ -282,6 +281,18 @@ $result = New-AzVmss -Credential $vmCred -VMScaleSetName $vmssName1 -ImageName $
282281

283282
This example Creates a new VMSS with the new Security Type 'TrustedLaunch' and the necessary UEFISettings values,
284283

284+
### Example 6: Create a Vmss in Orchestration Mode: Flexible by default
285+
```powershell
286+
# Create configration object
287+
$vmssConfig = New-AzVmssConfig -Location EastUs2 -UpgradePolicyMode Manual -SinglePlacementGroup $true
288+
289+
# VMSS Creation
290+
New-AzVmss -ResourceGroupName TestRg -VMScaleSetName myVMSS -VirtualMachineScaleSet $vmssConfig
291+
292+
```
293+
294+
This example Creates a new VMSS and it will default to OrchestrationMode Flexible.
295+
285296
## PARAMETERS
286297

287298
### -AllocationMethod

0 commit comments

Comments
 (0)