From af1ac14ae253ef3a60113e9553e77de17723fb43 Mon Sep 17 00:00:00 2001 From: aneeshakella-microsoft <109654329+aneeshakella-microsoft@users.noreply.github.com> Date: Fri, 25 Aug 2023 00:36:10 -0700 Subject: [PATCH] Adding Autoscaling Capabilities to Virtual Network Gateway (#22637) * Bump up version for KeyVault (#22511) * Merge remote-tracking branch 'upstream/main' into lnx/azurecore (#22349) Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Exclude the api-version in typename when checking the breaking change of cmdlet output (#22495) * Exclude the api-version in typename when checking the breaking change of cmdlet output * Rename the function * fix Get-AzVmRunCommand bug (#22460) * fix bug * changelog --------- Co-authored-by: Theodore Chang * Add permission for pr-label github actions (#22481) * Add permission for pr-label github actions * Add permission for pr-label github actions * Add permission for pr-label github actions * Add permission for pr-label github actions * Update Remove-AzApiManagementApiFromGateway.md (#22505) Added the example of removing an API from a managed gateway. Users are not able to achieve it by following the first example and raising questions using support tickets. * Migrate StackHCI from generation to main (#22541) * Move StackHCI to main * udpate changelog --------- Co-authored-by: YanaXu * [KeyVault] Support MHSM Settings (#22525) * wip * add update-azkeyvaultsetting and help docs * add example for settings * add change log * add live test * fix * fix * Migrate ContainerInstance from generation to main (#22537) * Move ContainerInstance to main * Create containerGroups-containers.json * Create containerGroups.json --------- Co-authored-by: Beisi Zhou * Updated ChangeLog.md for Az.ContainerInstance (#22550) * Updated ChangeLog.md for Az.ContainerInstance * Update src/ContainerInstance/ChangeLog.md --------- Co-authored-by: Beisi Zhou * [Synapse] Update artifact to 1.0.0-preview.18 (#22452) * update artifact to 18 * fix change log error * workaround the assembly loading issue (#22551) * [Compute] update sdk package reference for Compute (#22459) * update SDK reference * resolve breaking change * update package reference * breaking change mitigation * breaking change suppression * re-record ssh test with latest compute API call --------- Co-authored-by: Theodore Chang * Bump up version for StackHCI (#22543) * Compute migration to track 1 deprecation (#21949) * add compute.sdk project reference * add sdk folder * address comments * update commit version to inputs * rename Compute.Sdk folder to Compute.Management.Sdk * resolve xmls, change compute.sdk reference to compute.management.sdk * remove SDK reference. generate track 1 with latest DiskRP version * Update src/Compute/Compute.Management.Sdk/README.md Co-authored-by: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> * fix autorest cmd * update autorest gen * Update Compute.Management.Sdk.csproj * generated with latest swagger versions. 2023-04-02 diskRP 2023-07-01 CRP * update assembly version of sdk --------- Co-authored-by: Theodore Chang Co-authored-by: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> * [KeyVault] Added security domain properties into PSManagedHsm (#22540) * Refresh track 1 SDK * Added security domain properties into the output of New/Update/Get-AzKeyVaultManagedHsm (PSManagedHsm) * Refresh example * hibernate parameter for Stop-AzVmss (#22560) Co-authored-by: Theodore Chang * Update PrLabeled.ps1 (#22553) * Adding XenonMV3 Support (#22530) * adding PremiumMV3 to Xenon list * updating changelog --------- Co-authored-by: Nalin Gaddis * Upgraded vulnerable DLLs after upgrading PowerShell SDK (#22566) * Update New-AzVirtualNetworkSubnetConfig.md (#22561) `New-AzVirtualSubnetConfig` does not exists but `New-AzVirtualNetworkSubnetConfig` does. * Generate aks sdk with autorest.powershell (#22501) * Generate aks sdk with autorest.powershell * Suppress breaking changes caused by character case change * [KeyVault] Add live tests for MHSM Settings (#22570) * Add live tests for MHSM Settings * enable all test cases * [Config] add config to disable write error to file system (#22529) * disable error records persistence * add keys * upgrade common version * polish help message for 'DisableErrorRecordsPersistence' * Update src/Accounts/Authentication/Properties/Resources.resx Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * remove debug parameters for get/clear/update config * update environment variable name to AzPSDisableErrorRecordsPersistence --------- Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> * Updated email notification to support multi-recipients (#22577) * Use autorest.powershell to generate AlertsManagement SDK to replace the track 1 SDK (#22579) * [Storage] Support encryption context property when creating a datalakegen2 item (#22563) * encryption context * Add changelog * update test dependency and help file * Add an example for encryption context * Migrate StackHCI from generation to main (#22588) * Move StackHCI to main * update changelog --------- Co-authored-by: YanaXu * Support deployment stack object as input parameter for Save-Az*DeploymentStack and Remove-Az*DeploymentStack cmdlets (#22519) * implemented stack object parameter sets for save and remove cmdlets * adjust tests and session records * adjusted changelog to reflect changes * adjust testing formatting * updating help docs * update cmdlets and help docs for renamed parameter * update sessions record tests * Migrate DataMigration from generation to main (#22574) * Move DataMigration to main * update ChangeLog --------- Co-authored-by: YanaXu * change breaking change info (#22571) * Fixed type conversion issue when sending email in live test (#22596) * Skip Accounts when run static analysis check in generation ci (#22597) * [HDInsight] Add warning message for break changes which plan to release in Nov. (#22578) * Update Azure.Core from 1.31.0 to 1.33.0 * replace models * Revert "replace models" This reverts commit d1a1de35f3e38a0f00fe767818304a84086d5abf. * add Warning message 1 * Update Azure.Core version to 1.34 * revert added package. * Update change log * Update changelog * move changelog to Upcoming release --------- Co-authored-by: v-yuchenli * Update code-oob.yml for Azure Pipelines (#22591) * Update code-oob.yml for Azure Pipelines * Update code-oob.yml for Azure Pipelines * Update code-oob.yml for Azure Pipelines * Update code-oob.yml for Azure Pipelines * Update code-oob.yml for Azure Pipelines * [KeyVault] Formatted the table view of outputs (#22580) * Formatted the table view of *-AzKeyVault, *-AzKeyVaultKey and *-AzKeyVaultSecret * format cert * reorg folder constructure * Update src/KeyVault/KeyVault.Test/UnitTests/SetKeyVaultSecretTests.cs * Update src/KeyVault/KeyVault.Test/UnitTests/RemoveKeyVaultSecretTests.cs * Update src/KeyVault/KeyVault/KeyVault.csproj * Update Maintenance ChangeLog.md (#22602) * Update ChangeLog.md * Update ChangeLog.md * Update ChangeLog.md * Skip Accounts when run static analysis check in generation ci (#22603) * Skip Accounts when run static analysis check in generation ci * Skip Accounts when run static analysis check in generation ci * Skip Accounts when run static analysis check in generation ci * Add SecurityType of Standard to VM and VMSS cmdlets for Trusted Launch, includes breaking changes (#22534) * initial dev * successful test 1 * vmss test and rest of dev * vmss with config test * vm with config test * tests fixed maybe 1 fails * static analysis * remove vmss validation * null check * changelog and help doc * constant values * clean * valids and clean * Update BreakingChangeIssues.csv * remove breaking * Update BreakingChangeIssues.csv * Sign old modules (#22609) * Update ChangeLog.md * Update ChangeLog.md * Update ChangeLog.md * Update ChangeLog.md * Update ChangeLog.md * Migrate SqlVirtualMachine from generation to main (#22608) * Move SqlVirtualMachine to main * update Changelog --------- Co-authored-by: YanaXu * Migrate EventHub from generation to main (#22610) * Move EventHub to main * update ChangeLog --------- Co-authored-by: YanaXu * Refill Credentials from AzKeyStore When Save AzContext (#22440) * Refill Credentials from AzKeyStore When Save AzContext fix https://github.com/Azure/azure-powershell/issues/22355 * Address review comments * Address review comments * CosmosDB - New Restore Parameter (#22585) * restore new param public network access * minor fixes * test change * stable changes 1 * md param def changed * reverting test changes for build * restore ts * test and test recording * Migrate KeyVault from generation to main (#22621) * Move KeyVault to main * Update ChangeLog.md --------- Co-authored-by: Beisi Zhou * FabricBot: Onboarding to GitOps.ResourceManagement because of FabricBot decommissioning (#22343) * Add prIssueManagement.yml to onboard repo to GitOps.ResourceManagement as FabricBot replacement Owners of the FabricBot configuration should have received email notification. The same information contained in the email is published internally at: https://aka.ms/gim/fabricbot. Details on the replacement service and the syntax of the new yaml configuration file is available publicly at: https://microsoft.github.io/GitOps/policies/resource-management.html Please review and merge this PR to complete the process of onboarding to the new service. * Deleting fabricbot.json * Update resourceManagement.yml --------- Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> Co-authored-by: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> * [KeyVault] Update TestSetting.ps1 to run on one platform and latest powershell (#22618) * Update TestSetting.ps1 * Update KeyVault.sln * first set of changes * created initial powershell for ergwscale * edited changelog * update warning message (#22619) * Fix to only include non-empty ExtendedLocation (#22630) * Fix to only include non-empty ExtendedLocation * Updated ChangeLog.md * Remove PS 7.0 from smoke test (#22569) * Alias Set-AzConfig (#22629) * updated files due to failing test * formatting changes * formatting changes * Revert "formatting changes" This reverts commit d8900c5e5c6b655eaf5b5bec097c9441657319ba. * Revert " fixed merge issues" This reverts commit bc4af7844953cef6a4a793bde3c8b8898aeca960, reversing changes made to d8900c5e5c6b655eaf5b5bec097c9441657319ba. * finished changes * formatting * formatting * formatting * edited ChangeLog * added empty line * added empty line between 6.1.1 and 6.1.0 --------- Co-authored-by: Azure PowerShell <65331932+azure-powershell-bot@users.noreply.github.com> Co-authored-by: NanxiangLiu <33285578+Nickcandy@users.noreply.github.com> Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com> Co-authored-by: Yunchi Wang <54880216+wyunchi-ms@users.noreply.github.com> Co-authored-by: Theodore Chang Co-authored-by: Theodore Chang Co-authored-by: Saurav Raghuvanshi <47741547+sauravraghuvanshi@users.noreply.github.com> Co-authored-by: YanaXu Co-authored-by: Beisi Zhou Co-authored-by: Andrey Goran Co-authored-by: kevinzz6 <632604666@qq.com> Co-authored-by: Vincent Dai <23257217+vidai-msft@users.noreply.github.com> Co-authored-by: Nalin Gaddis <33502801+nalingaddis@users.noreply.github.com> Co-authored-by: Nalin Gaddis Co-authored-by: Preston Alvarado <700740+coolhome@users.noreply.github.com> Co-authored-by: Xiaogang Co-authored-by: Yabo Hu Co-authored-by: yifanz7 <131133995+yifanz7@users.noreply.github.com> Co-authored-by: Dante Co-authored-by: yuc-Li <58678302+yuc-Li@users.noreply.github.com> Co-authored-by: v-yuchenli Co-authored-by: Adam Sandor Co-authored-by: Jin Lei <54836179+msJinLei@users.noreply.github.com> Co-authored-by: mayankkatwal <121567171+mayankkatwal@users.noreply.github.com> Co-authored-by: microsoft-github-policy-service[bot] <77245923+microsoft-github-policy-service[bot]@users.noreply.github.com> Co-authored-by: myun12580 <133928614+myun12580@users.noreply.github.com> --- .../Models/VirtualNetworkGatewaySkuTier.cs | 1 + src/Network/Network/ChangeLog.md | 1 + .../Network/Models/PSVirtualNetworkGateway.cs | 5 ++- ...ualNetworkGatewayAutoscaleConfiguration.cs | 32 ++++++++++++++ ...yPropertiesAutoScaleConfigurationBounds.cs | 14 ++++++ src/Network/Network/Network.format.ps1xml | 44 +++++++++++++++++++ .../NewAzureVirtualNetworkGatewayCommand.cs | 44 ++++++++++++++----- ...UpdateAzureVirtualNetworkGatewayCommand.cs | 19 ++++++++ .../help/New-AzVirtualNetworkGateway.md | 1 + .../help/Set-AzVirtualNetworkGateway.md | 2 +- 10 files changed, 149 insertions(+), 14 deletions(-) create mode 100644 src/Network/Network/Models/PSVirtualNetworkGatewayAutoscaleConfiguration.cs create mode 100644 src/Network/Network/Models/PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds.cs diff --git a/src/Network/Network.Management.Sdk/Generated/Models/VirtualNetworkGatewaySkuTier.cs b/src/Network/Network.Management.Sdk/Generated/Models/VirtualNetworkGatewaySkuTier.cs index 9d353fbe6d04..40c9f3564232 100644 --- a/src/Network/Network.Management.Sdk/Generated/Models/VirtualNetworkGatewaySkuTier.cs +++ b/src/Network/Network.Management.Sdk/Generated/Models/VirtualNetworkGatewaySkuTier.cs @@ -33,5 +33,6 @@ public static class VirtualNetworkGatewaySkuTier public const string ErGw1AZ = "ErGw1AZ"; public const string ErGw2AZ = "ErGw2AZ"; public const string ErGw3AZ = "ErGw3AZ"; + public const string ErGwScale = "ErGwScale"; } } diff --git a/src/Network/Network/ChangeLog.md b/src/Network/Network/ChangeLog.md index 3962475d7ea4..d52a81121e01 100644 --- a/src/Network/Network/ChangeLog.md +++ b/src/Network/Network/ChangeLog.md @@ -24,6 +24,7 @@ * Onboarded `Microsoft.EventGrid/namespaces` to private link cmdlets * Fixed bug in `NewAzureApplicationGatewayFirewallCustomRuleGroupByVariable` to add "GeoLocation" as a valid input for VariableName * Added breaking change message for parameter `VariableName` in `NewAzureApplicationGatewayFirewallCustomRuleGroupByVariable` to remove "Geo" as a valid input. +* Added min scale units and max scale units to support autoscale for Virtual Network gateways ## Version 6.1.1 * Onboarded `Microsoft.ElasticSan/elasticSans` to private link cmdlets diff --git a/src/Network/Network/Models/PSVirtualNetworkGateway.cs b/src/Network/Network/Models/PSVirtualNetworkGateway.cs index 28aafe74f774..4a54aa55eb4f 100644 --- a/src/Network/Network/Models/PSVirtualNetworkGateway.cs +++ b/src/Network/Network/Models/PSVirtualNetworkGateway.cs @@ -48,8 +48,11 @@ public class PSVirtualNetworkGateway : PSTopLevelResource [Ps1Xml(Label = "Sku Name", Target = ViewControl.Table, ScriptBlock = "$_.Sku.Name")] public PSVirtualNetworkGatewaySku Sku { get; set; } - public List VirtualNetworkGatewayPolicyGroups { get; set; } + [Ps1Xml(Label = "AutoScaleConfiguration", Target = ViewControl.Table)] + public PSVirtualNetworkGatewayAutoscaleConfiguration AutoScaleConfiguration { get; set; } + public List VirtualNetworkGatewayPolicyGroups { get; set; } + public PSVpnClientConfiguration VpnClientConfiguration { get; set; } public PSBgpSettings BgpSettings { get; set; } diff --git a/src/Network/Network/Models/PSVirtualNetworkGatewayAutoscaleConfiguration.cs b/src/Network/Network/Models/PSVirtualNetworkGatewayAutoscaleConfiguration.cs new file mode 100644 index 000000000000..052ca85f58c8 --- /dev/null +++ b/src/Network/Network/Models/PSVirtualNetworkGatewayAutoscaleConfiguration.cs @@ -0,0 +1,32 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using Microsoft.WindowsAzure.Commands.Common.Attributes; +using Newtonsoft.Json; + +namespace Microsoft.Azure.Commands.Network.Models +{ + public class PSVirtualNetworkGatewayAutoscaleConfiguration + { + [Ps1Xml(Target = ViewControl.Table)] + public PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds Bounds { get; set; } + + [JsonIgnore] + public string BoundsText + { + get { return JsonConvert.SerializeObject(Bounds, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } + } + } +} diff --git a/src/Network/Network/Models/PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds.cs b/src/Network/Network/Models/PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds.cs new file mode 100644 index 000000000000..5942fc5d54d0 --- /dev/null +++ b/src/Network/Network/Models/PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds.cs @@ -0,0 +1,14 @@ + +using Microsoft.WindowsAzure.Commands.Common.Attributes; + +namespace Microsoft.Azure.Commands.Network.Models +{ + public class PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds + { + [Ps1Xml(Target = ViewControl.Table)] + public int Min { get; set; } + + [Ps1Xml(Target = ViewControl.Table)] + public int Max { get; set; } + } +} \ No newline at end of file diff --git a/src/Network/Network/Network.format.ps1xml b/src/Network/Network/Network.format.ps1xml index a5abab60cfdb..969ab4e705e2 100644 --- a/src/Network/Network/Network.format.ps1xml +++ b/src/Network/Network/Network.format.ps1xml @@ -976,6 +976,10 @@ SkuText + + + AutoScaleConfigurationText + VpnClientConfigurationText @@ -6130,6 +6134,46 @@ + + Microsoft.Azure.Commands.Network.Models.PSVirtualNetworkGatewayAutoscaleConfiguration + + Microsoft.Azure.Commands.Network.Models.PSVirtualNetworkGatewayAutoscaleConfiguration + + + + + + + + BoundsText + + + + + + + + Microsoft.Azure.Commands.Network.Models.PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds + + Microsoft.Azure.Commands.Network.Models.PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds + + + + + + + + Min + + + + Max + + + + + + Microsoft.Azure.Commands.Network.Models.PSVirtualNetworkGatewayConnectionIkeSaQuickModeSa diff --git a/src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs b/src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs index 441ca9e7788d..9846e6063ec5 100644 --- a/src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs +++ b/src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs @@ -29,7 +29,7 @@ namespace Microsoft.Azure.Commands.Network { - [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkGateway",SupportsShouldProcess = true,DefaultParameterSetName = VirtualNetworkGatewayParameterSets.Default),OutputType(typeof(PSVirtualNetworkGateway))] + [Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualNetworkGateway", SupportsShouldProcess = true, DefaultParameterSetName = VirtualNetworkGatewayParameterSets.Default), OutputType(typeof(PSVirtualNetworkGateway))] public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmdlet { [Alias("ResourceName")] @@ -144,6 +144,7 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd MNM.VirtualNetworkGatewaySkuTier.ErGw1AZ, MNM.VirtualNetworkGatewaySkuTier.ErGw2AZ, MNM.VirtualNetworkGatewaySkuTier.ErGw3AZ, + MNM.VirtualNetworkGatewaySkuTier.ErGwScale, IgnoreCase = true)] public string GatewaySku { get; set; } @@ -313,6 +314,12 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] public SwitchParameter AsJob { get; set; } + [Parameter(Mandatory = false, HelpMessage = "Set min scale units for scalable gateways")] + public Int32 MinScaleUnit { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Set max scale units for scalable gateways")] + public Int32 MaxScaleUnit { get; set; } + [Parameter( Mandatory = false, ValueFromPipelineByPropertyName = true, @@ -324,7 +331,7 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd [PSArgumentCompleter( "Enabled", "Disabled")] - public string AdminState { get; set; } + public string AdminState { get; set; } public override void Execute() { @@ -337,7 +344,7 @@ public override void Execute() var isCertConfigured = (this.VpnClientRootCertificates != null && this.VpnClientRootCertificates.Count() > 0) || (this.VpnClientRevokedCertificates != null && this.VpnClientRevokedCertificates.Count() > 0); var isRadiusConfigured = !string.IsNullOrEmpty(this.RadiusServerAddress) && this.RadiusServerSecret != null && !string.IsNullOrEmpty(SecureStringExtensions.ConvertToString(this.RadiusServerSecret)); var isAadConfigured = this.AadTenantUri != null && this.AadAudienceId != null && this.AadIssuerUri != null; - + if (!string.IsNullOrEmpty(GatewaySku) && GatewaySku.Equals(MNM.VirtualNetworkGatewaySkuTier.UltraPerformance, StringComparison.InvariantCultureIgnoreCase)) { @@ -502,7 +509,7 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway() vnetGateway.VpnClientConfiguration.RadiusServerAddress = this.RadiusServerAddress; vnetGateway.VpnClientConfiguration.RadiusServerSecret = SecureStringExtensions.ConvertToString(this.RadiusServerSecret); } - + if (this.RadiusServerList != null && this.RadiusServerList.Any()) { vnetGateway.VpnClientConfiguration.RadiusServers = this.RadiusServerList?.ToList(); @@ -543,12 +550,12 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway() if (this.ClientConnectionConfiguration != null && this.ClientConnectionConfiguration.Any()) { - foreach( var config in this.ClientConnectionConfiguration) + foreach (var config in this.ClientConnectionConfiguration) { - foreach (var policyGroup in config.VirtualNetworkGatewayPolicyGroups) + foreach (var policyGroup in config.VirtualNetworkGatewayPolicyGroups) { policyGroup.Id = string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/virtualNetworkGateways/{2}/virtualNetworkGatewayPolicyGroups/{3}", this.NetworkClient.NetworkManagementClient.SubscriptionId, vnetGateway.ResourceGroupName, Name, policyGroup.Id); - } + } } vnetGateway.VpnClientConfiguration.ClientConnectionConfigurations = this.ClientConnectionConfiguration.ToList(); } @@ -580,12 +587,12 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway() if (this.IpConfigurationBgpPeeringAddresses != null) { - if(vnetGateway.BgpSettings == null) + if (vnetGateway.BgpSettings == null) { vnetGateway.BgpSettings = new PSBgpSettings(); } - if(this.IpConfigurationBgpPeeringAddresses.Any(address => address.CustomBgpIpAddresses == null || !address.CustomBgpIpAddresses.Any())) + if (this.IpConfigurationBgpPeeringAddresses.Any(address => address.CustomBgpIpAddresses == null || !address.CustomBgpIpAddresses.Any())) { throw new ArgumentException("if IpConfigurationBgpPeeringAddresses are provided, CustomBgpIpAddresses must be a provided in create gateway"); } @@ -598,7 +605,7 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway() vnetGateway.BgpSettings.BgpPeeringAddresses.Add(address); } } - else if(vnetGateway.BgpSettings != null) + else if (vnetGateway.BgpSettings != null) { vnetGateway.BgpSettings.BgpPeeringAddresses = null; } @@ -639,7 +646,20 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway() vnetGateway.AdminState = this.AdminState; } - + + // set the min scale units and the max scale units + if (!string.IsNullOrEmpty(this.GatewaySku) && this.GatewaySku.Equals(MNM.VirtualNetworkGatewaySkuTier.ErGwScale)) + { + if (this.MaxScaleUnit > 0 && this.MinScaleUnit > this.MaxScaleUnit) + { + throw new PSArgumentException(string.Format(Properties.Resources.InvalidAutoScaleConfiguration, this.MinScaleUnit, this.MaxScaleUnit)); + } + + vnetGateway.AutoScaleConfiguration = new PSVirtualNetworkGatewayAutoscaleConfiguration(); + vnetGateway.AutoScaleConfiguration.Bounds = new PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds(); + vnetGateway.AutoScaleConfiguration.Bounds.Min = Convert.ToInt32(this.MinScaleUnit); + vnetGateway.AutoScaleConfiguration.Bounds.Max = (this.MaxScaleUnit > 0) ? Convert.ToInt32(this.MaxScaleUnit) : Convert.ToInt32(this.MinScaleUnit); + } // Set the EnableBgpRouteTranslationForNat, if it is specified by customer. vnetGateway.EnableBgpRouteTranslationForNat = EnableBgpRouteTranslationForNat.IsPresent; @@ -655,4 +675,4 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway() return getVirtualNetworkGateway; } } -} +} \ No newline at end of file diff --git a/src/Network/Network/VirtualNetworkGateway/UpdateAzureVirtualNetworkGatewayCommand.cs b/src/Network/Network/VirtualNetworkGateway/UpdateAzureVirtualNetworkGatewayCommand.cs index 36bff48bf9b3..4c90fd1d0386 100644 --- a/src/Network/Network/VirtualNetworkGateway/UpdateAzureVirtualNetworkGatewayCommand.cs +++ b/src/Network/Network/VirtualNetworkGateway/UpdateAzureVirtualNetworkGatewayCommand.cs @@ -60,6 +60,7 @@ public class SetAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd MNM.VirtualNetworkGatewaySkuTier.ErGw1AZ, MNM.VirtualNetworkGatewaySkuTier.ErGw2AZ, MNM.VirtualNetworkGatewaySkuTier.ErGw3AZ, + MNM.VirtualNetworkGatewaySkuTier.ErGwScale, IgnoreCase = true)] public string GatewaySku { get; set; } @@ -213,6 +214,11 @@ public class SetAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd HelpMessage = "This will enable and disable BgpRouteTranslationForNat on this VirtualNetworkGateway.")] public bool? BgpRouteTranslationForNat { get; set; } + [Parameter(Mandatory = false, HelpMessage = "Set min scale units for scalable gateways")] + public Int32 MinScaleUnit { get; set; } + + [Parameter(Mandatory = false, HelpMessage = "Set max scale units for scalable gateways")] + public Int32 MaxScaleUnit { get; set; } [Parameter( Mandatory = false, @@ -531,6 +537,19 @@ public override void Execute() this.VirtualNetworkGateway.AdminState = AdminState; } + if (!string.IsNullOrEmpty(this.VirtualNetworkGateway.Sku.Name) && (this.VirtualNetworkGateway.Sku.Name.Equals(MNM.VirtualNetworkGatewaySkuTier.ErGwScale) && (this.MinScaleUnit > 0 || this.MaxScaleUnit > 0))) + { + if (this.MinScaleUnit > this.MaxScaleUnit) + { + throw new PSArgumentException(string.Format(Properties.Resources.InvalidAutoScaleConfiguration, this.MinScaleUnit, this.MaxScaleUnit)); + } + + this.VirtualNetworkGateway.AutoScaleConfiguration = new PSVirtualNetworkGatewayAutoscaleConfiguration(); + this.VirtualNetworkGateway.AutoScaleConfiguration.Bounds = new PSVirtualNetworkGatewayPropertiesAutoScaleConfigurationBounds(); + this.VirtualNetworkGateway.AutoScaleConfiguration.Bounds.Min = Convert.ToInt32(this.MinScaleUnit); + this.VirtualNetworkGateway.AutoScaleConfiguration.Bounds.Max = Convert.ToInt32(this.MaxScaleUnit); + } + // Map to the sdk object MNM.VirtualNetworkGateway sdkVirtualNetworkGateway = NetworkResourceManagerProfile.Mapper.Map(this.VirtualNetworkGateway); sdkVirtualNetworkGateway.Tags = diff --git a/src/Network/Network/help/New-AzVirtualNetworkGateway.md b/src/Network/Network/help/New-AzVirtualNetworkGateway.md index edc914f18a5c..f2c9f2520394 100644 --- a/src/Network/Network/help/New-AzVirtualNetworkGateway.md +++ b/src/Network/Network/help/New-AzVirtualNetworkGateway.md @@ -18,6 +18,7 @@ New-AzVirtualNetworkGateway -Name -ResourceGroupName -Location [-IpConfigurations ] [-GatewayType ] [-ExtendedLocation ] [-VNetExtendedLocationResourceId ] [-VpnType ] [-EnableBgp ] [-DisableIPsecProtection ] [-EnableActiveActiveFeature] + [-MinScaleUnit ] [-MaxScaleUnit ] [-EnablePrivateIpAddress] [-GatewaySku ] [-GatewayDefaultSite ] [-VpnClientAddressPool ] [-VpnClientProtocol ] [-VpnAuthenticationType ] [-VpnClientRootCertificates ] diff --git a/src/Network/Network/help/Set-AzVirtualNetworkGateway.md b/src/Network/Network/help/Set-AzVirtualNetworkGateway.md index ced546006715..daa22355ef8b 100644 --- a/src/Network/Network/help/Set-AzVirtualNetworkGateway.md +++ b/src/Network/Network/help/Set-AzVirtualNetworkGateway.md @@ -20,7 +20,7 @@ Set-AzVirtualNetworkGateway -VirtualNetworkGateway [-G [-VpnClientProtocol ] [-VpnAuthenticationType ] [-VpnClientRootCertificates ] [-VpnClientRevokedCertificates ] [-VpnClientIpsecPolicy ] - [-Asn ] [-PeerWeight ] + [-Asn ] [-PeerWeight ] [-MinScaleUnit ] [-MaxScaleUnit ] [-IpConfigurationBgpPeeringAddresses ] [-EnableActiveActiveFeature] [-EnablePrivateIpAddress ] [-DisableActiveActiveFeature] [-RadiusServerAddress ] [-RadiusServerSecret ] [-RadiusServerList ] [-AadTenantUri ]