diff --git a/src/Network/Network/ChangeLog.md b/src/Network/Network/ChangeLog.md index 28d3bc76dd72..f622fe24f8d9 100644 --- a/src/Network/Network/ChangeLog.md +++ b/src/Network/Network/ChangeLog.md @@ -43,6 +43,16 @@ ## Version 4.16.1 * Fixed `ArgumentNullException` in `Add-AzureRmRouteConfig` when `RouteTable.Routes` is null. +* Added new cmdlets for RoutingIntent child resource of VirtualHub. + -`Add-AzRoutingPolicy` + -`Get-AzRoutingPolicy` + -`New-AzRoutingPolicy` + -`Remove-AzRoutingPolicy` + -`Set-AzRoutingPolicy` + -`Get-AzRoutingIntent` + -`New-AzRoutingIntent` + -`Remove-AzRoutingIntent` + -`Set-AzRoutingIntent` ## Version 4.16.0 * Added support for retrieving the state of packet capture even when the provisioning state of the packet capture was failure diff --git a/src/Network/Network/Common/NetworkResourceManagerProfile.cs b/src/Network/Network/Common/NetworkResourceManagerProfile.cs index fb2b01abd90e..40df0dff129f 100644 --- a/src/Network/Network/Common/NetworkResourceManagerProfile.cs +++ b/src/Network/Network/Common/NetworkResourceManagerProfile.cs @@ -1231,6 +1231,15 @@ private static void Initialize() cfg.CreateMap(); cfg.CreateMap(); + //// Virtual Hub Routing Intent + // CNM to MNM + cfg.CreateMap(); + cfg.CreateMap(); + + // MNM to CNM + cfg.CreateMap(); + cfg.CreateMap(); + // Virtual wan Point to site // MNM to CNM cfg.CreateMap(); diff --git a/src/Network/Network/Cortex/CortexParameterSetNames.cs b/src/Network/Network/Cortex/CortexParameterSetNames.cs index 19a4b9d508fa..d93f40dc8ad8 100644 --- a/src/Network/Network/Cortex/CortexParameterSetNames.cs +++ b/src/Network/Network/Cortex/CortexParameterSetNames.cs @@ -84,5 +84,9 @@ internal static class CortexParameterSetNames internal const string ByHubBgpConnectionObject = "ByHubBgpConnectionObject"; internal const string ByHubBgpConnectionResourceId = "ByHubBgpConnectionResourceId"; - } + internal const string ByRoutingIntentName = "ByRoutingInctentName"; + internal const string ByRoutingIntentResourceId = "ByRoutingInctentResourceId"; + internal const string ByRoutingIntentObject = "ByRoutingInctentObject"; + + } } \ No newline at end of file diff --git a/src/Network/Network/Cortex/RoutingIntent/GetAzureRmRoutingIntentCommand.cs b/src/Network/Network/Cortex/RoutingIntent/GetAzureRmRoutingIntentCommand.cs new file mode 100644 index 000000000000..3403bad178ad --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/GetAzureRmRoutingIntentCommand.cs @@ -0,0 +1,98 @@ + +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; + using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; + + [Cmdlet(VerbsCommon.Get, + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingIntent", + DefaultParameterSetName = CortexParameterSetNames.ByVirtualHubName), + OutputType(typeof(PSRoutingIntent))] + public class GetAzureRmRoutingIntentCommand : RoutingIntentBaseCmdlet + { + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubName, + HelpMessage = "The resource group name.")] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + public string ResourceGroupName { get; set; } + + [Alias("VirtualHubName", "ParentVirtualHubName", "ParentResourceName")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubName, + HelpMessage = "The parent resource name.")] + [ResourceNameCompleter("Microsoft.Network/virtualHubs", "ResourceGroupName")] + public string HubName { get; set; } + + [Alias("ParentObject", "ParentVirtualHub")] + [Parameter( + Mandatory = true, + ValueFromPipeline = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubObject, + HelpMessage = "The parent resource.")] + public PSVirtualHub VirtualHub { get; set; } + + [Alias("VirtualHubId", "ParentVirtualHubId")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubResourceId, + HelpMessage = "The parent resource id.")] + [ResourceIdCompleter("Microsoft.Network/virtualHubs")] + public string ParentResourceId { get; set; } + + [Alias("ResourceName", "RoutingIntentName")] + [Parameter( + Mandatory = false, + HelpMessage = "The resource name.")] + [ResourceNameCompleter("Microsoft.Network/virtualHubs/routingIntent", "ResourceGroupName", "ParentResourceName")] + [ValidateNotNullOrEmpty] + [SupportsWildcards] + public string Name { get; set; } + + public override void Execute() + { + base.Execute(); + + if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualHubObject, StringComparison.OrdinalIgnoreCase)) + { + this.HubName = this.VirtualHub.Name; + this.ResourceGroupName = this.VirtualHub.ResourceGroupName; + } + else if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualHubResourceId, StringComparison.OrdinalIgnoreCase)) + { + var parsedResourceId = new ResourceIdentifier(this.ParentResourceId); + this.HubName = parsedResourceId.ResourceName; + ResourceGroupName = parsedResourceId.ResourceGroupName; + } + + if (ShouldGetByName(ResourceGroupName, Name)) + { + WriteObject(GetRoutingIntent(this.ResourceGroupName, this.HubName, this.Name)); + } + else + { + WriteObject(SubResourceWildcardFilter(Name, this.ListRoutingIntents(this.ResourceGroupName, this.HubName)), true); + } + } + } +} diff --git a/src/Network/Network/Cortex/RoutingIntent/NewAzureRmRoutingIntentCommand.cs b/src/Network/Network/Cortex/RoutingIntent/NewAzureRmRoutingIntentCommand.cs new file mode 100644 index 000000000000..58b72504a747 --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/NewAzureRmRoutingIntentCommand.cs @@ -0,0 +1,119 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System; + using System.Linq; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; + using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; + + [Cmdlet(VerbsCommon.New, + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingIntent", + DefaultParameterSetName = CortexParameterSetNames.ByVirtualHubName, + SupportsShouldProcess = true), + OutputType(typeof(PSRoutingIntent))] + public class NewAzureRmRoutingIntentCommand : RoutingIntentBaseCmdlet + { + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubName, + HelpMessage = "The resource group name.")] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + public string ResourceGroupName { get; set; } + + [Alias("VirtualHubName", "ParentVirtualHubName")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubName, + HelpMessage = "The resource group name.")] + public string ParentResourceName { get; set; } + + [Alias("VirtualHub", "ParentVirtualHub")] + [Parameter( + Mandatory = true, + ValueFromPipeline = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubObject, + HelpMessage = "The parent resource.")] + public PSVirtualHub ParentObject { get; set; } + + [Alias("VirtualHubId", "ParentVirtualHubId")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubResourceId, + HelpMessage = "The parent resource.")] + [ResourceIdCompleter("Microsoft.Network/virtualHubs")] + public string ParentResourceId { get; set; } + + [Alias("ResourceName", "RoutingIntentName", "RoutingIntentName")] + [Parameter( + Mandatory = true, + HelpMessage = "Name of the routing intent resource.")] + public string Name { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The list of policies for this routing intent resource.")] + public PSRoutingPolicy[] RoutingPolicy { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "Run cmdlet in the background")] + public SwitchParameter AsJob { get; set; } + + public override void Execute() + { + base.Execute(); + + if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualHubObject, StringComparison.OrdinalIgnoreCase)) + { + this.ResourceGroupName = this.ParentObject.ResourceGroupName; + this.ParentResourceName = this.ParentObject.Name; + } + else if (ParameterSetName.Contains(CortexParameterSetNames.ByVirtualHubResourceId)) + { + var parsedResourceId = new ResourceIdentifier(this.ParentResourceId); + this.ResourceGroupName = parsedResourceId.ResourceGroupName; + this.ParentResourceName = parsedResourceId.ResourceName; + } + + if (this.IsRoutingIntentPresent(this.ResourceGroupName, this.ParentResourceName, this.Name)) + { + throw new PSArgumentException(string.Format(Properties.Resources.ChildResourceAlreadyPresentInResourceGroup, this.Name, this.ResourceGroupName, this.ParentResourceName)); + } + + // this will thorw if hub does not exist. + IsParentVirtualHubPresent(this.ResourceGroupName, this.ParentResourceName); + + PSRoutingIntent routingIntent = new PSRoutingIntent + { + Name = this.Name, + RoutingPolicies = this.RoutingPolicy.ToList() + }; + + ConfirmAction( + Properties.Resources.CreatingResourceMessage, + this.Name, + () => + { + WriteVerbose(String.Format(Properties.Resources.CreatingLongRunningOperationMessage, this.ResourceGroupName, this.Name)); + WriteObject(this.CreateOrUpdateRoutingIntent(this.ResourceGroupName, this.ParentResourceName, this.Name, routingIntent)); + }); + } + } +} diff --git a/src/Network/Network/Cortex/RoutingIntent/RemoveAzureRmRoutingIntentCommand.cs b/src/Network/Network/Cortex/RoutingIntent/RemoveAzureRmRoutingIntentCommand.cs new file mode 100644 index 000000000000..0caa0ef917ca --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/RemoveAzureRmRoutingIntentCommand.cs @@ -0,0 +1,151 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System; + using System.Linq; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; + using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; + using Microsoft.Azure.Management.Network; + + [Cmdlet(VerbsCommon.Remove, + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingIntent", + DefaultParameterSetName = CortexParameterSetNames.ByRoutingIntentName, + SupportsShouldProcess = true), + OutputType(typeof(bool))] + public class RemoveAzureRmRoutingIntentCommand : RoutingIntentBaseCmdlet + { + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentName, + HelpMessage = "The resource group name.")] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + public string ResourceGroupName { get; set; } + + [Alias("VirtualHubName", "ParentVirtualHubName")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentName, + HelpMessage = "The resource group name.")] + public string ParentResourceName { get; set; } + + [Alias("ResourceName", "RoutingIntentName")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentName, + HelpMessage = "Name of the routing intent resource.")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubObject, + HelpMessage = "Name of therouting intent resource.")] + public string Name { get; set; } + + [Alias("VirtualHub", "ParentVirtualHub")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubObject, + HelpMessage = "The parent virtual hub object.")] + public PSVirtualHub ParentObject { get; set; } + + [Alias("RoutingIntent")] + [Parameter( + Mandatory = true, + ValueFromPipeline = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentObject, + HelpMessage = "The routing intent resource to delete.")] + public PSRoutingIntent InputObject { get; set; } + + [Alias("RoutingIntentId")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentResourceId, + HelpMessage = "The resource id of the routing intent to delete.")] + [ResourceIdCompleter("Microsoft.Network/virtualHubs/routingIntent")] + public string ResourceId { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "Run cmdlet in the background")] + public SwitchParameter AsJob { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "Do not ask for confirmation if you want to delete a resource")] + public SwitchParameter Force { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "Returns an object representing the item on which this operation is being performed.")] + public SwitchParameter PassThru { get; set; } + + public override void Execute() + { + base.Execute(); + PSRoutingIntent routingIntentToDelete = null; + if (ParameterSetName.Equals(CortexParameterSetNames.ByRoutingIntentObject, StringComparison.OrdinalIgnoreCase)) + { + routingIntentToDelete = this.InputObject; + this.ResourceId = this.InputObject.Id; + if (string.IsNullOrWhiteSpace(this.ResourceId)) + { + throw new PSArgumentException(Properties.Resources.RoutingIntentNotFound); + } + + var parsedResourceId = new ResourceIdentifier(this.ResourceId); + this.ResourceGroupName = parsedResourceId.ResourceGroupName; + this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); + this.Name = parsedResourceId.ResourceName; + } + else + { + if (ParameterSetName.Equals(CortexParameterSetNames.ByRoutingIntentResourceId, StringComparison.OrdinalIgnoreCase)) + { + var parsedResourceId = new ResourceIdentifier(this.ResourceId); + this.ResourceGroupName = parsedResourceId.ResourceGroupName; + this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); + this.Name = parsedResourceId.ResourceName; + } + else if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualHubObject, StringComparison.OrdinalIgnoreCase)) + { + var parentResourceId = this.ParentObject.Id; + var parsedParentResourceId = new ResourceIdentifier(parentResourceId); + this.ResourceGroupName = parsedParentResourceId.ResourceGroupName; + this.ParentResourceName = parsedParentResourceId.ResourceName; + } + } + + // this will thorw if hub does not exist. + IsParentVirtualHubPresent(this.ResourceGroupName, this.ParentResourceName); + + ConfirmAction( + Force.IsPresent, + string.Format(Properties.Resources.RemoveRoutingIntentWarning), + Properties.Resources.RemoveResourceMessage, + this.Name, + () => + { + RoutingIntentClient.Delete(this.ResourceGroupName, this.ParentResourceName, this.Name); + if (PassThru) + { + WriteObject(true); + } + }); + } + } +} diff --git a/src/Network/Network/Cortex/RoutingIntent/RoutingIntentBaseCmdlet.cs b/src/Network/Network/Cortex/RoutingIntent/RoutingIntentBaseCmdlet.cs new file mode 100644 index 000000000000..beb0b87ae7d6 --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/RoutingIntentBaseCmdlet.cs @@ -0,0 +1,88 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using AutoMapper; + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Management.Network; + using System; + using System.Collections.Generic; + using System.Management.Automation; + using MNM = Microsoft.Azure.Management.Network.Models; + + public class RoutingIntentBaseCmdlet : NetworkBaseCmdlet + { + public IRoutingIntentOperations RoutingIntentClient + { + get + { + return NetworkClient.NetworkManagementClient.RoutingIntent; + } + } + + public PSRoutingIntent ToPsRoutingIntent(MNM.RoutingIntent routingIntent) + { + var psRoutingIntent = NetworkResourceManagerProfile.Mapper.Map(routingIntent); + + return psRoutingIntent; + } + + public PSRoutingIntent GetRoutingIntent(string resourceGroupName, string virtualHubName, string name) + { + var routingIntent = RoutingIntentClient.Get(resourceGroupName, virtualHubName, name); + var psRoutingIntent = ToPsRoutingIntent(routingIntent); + + return psRoutingIntent; + } + + public List ListRoutingIntents(string resourceGroupName, string virtualHubName) + { + var routingIntents = RoutingIntentClient.List(resourceGroupName, virtualHubName); + + List routingIntentsToReturn = new List(); + if (routingIntents != null) + { + foreach (MNM.RoutingIntent routingIntent in routingIntents) + { + routingIntentsToReturn.Add(ToPsRoutingIntent(routingIntent)); + } + } + + return routingIntentsToReturn; + } + + public PSRoutingIntent CreateOrUpdateRoutingIntent(string resourceGroupName, string virtualHubName, string routingIntentName, PSRoutingIntent routingIntent) + { + var routingIntentModel = NetworkResourceManagerProfile.Mapper.Map(routingIntent); + var routingIntentCreated = RoutingIntentClient.CreateOrUpdate(resourceGroupName, virtualHubName, routingIntentName, routingIntentModel); + return ToPsRoutingIntent(routingIntentCreated); + } + + public bool IsRoutingIntentPresent(string resourceGroupName, string parentHubName, string name) + { + return IsResourcePresent(() => { GetRoutingIntent(resourceGroupName, parentHubName, name); }); + } + + public void IsParentVirtualHubPresent(string resourceGroupName, string parentHubName) + { + // Get the virtual hub - this will throw not found if the resource does not exist + PSVirtualHub resolvedVirtualHub = new VirtualHubBaseCmdlet().GetVirtualHub(resourceGroupName, parentHubName); + if (resolvedVirtualHub == null) + { + throw new PSArgumentException(Properties.Resources.ParentVirtualHubNotFound); + } + } + } +} \ No newline at end of file diff --git a/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/AddAzureRmRoutingPolicyCommand.cs b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/AddAzureRmRoutingPolicyCommand.cs new file mode 100644 index 000000000000..47c2bf56a1b7 --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/AddAzureRmRoutingPolicyCommand.cs @@ -0,0 +1,79 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + + [Cmdlet( + VerbsCommon.Add, + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingPolicy", + SupportsShouldProcess = false), + OutputType(typeof(PSRoutingIntent))] + public class AddAzureRmRoutingPolicyCommand : NetworkBaseCmdlet + { + [Parameter( + Mandatory = true, + HelpMessage = "The reference of the routing intent resource.", + ValueFromPipeline = true, + ValueFromPipelineByPropertyName = true)] + public PSRoutingIntent RoutingIntent { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "List of all destinations which this routing policy is applicable to (for example: Internet, PrivateTraffic).")] + [ValidateNotNullOrEmpty] + public string[] Destination { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The next hop resource id on which this routing policy is applicable to.")] + [ValidateNotNullOrEmpty] + public string NextHop { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The unique name for this routing policy.")] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + public override void Execute() + { + var existingRoutingPolicy = this.RoutingIntent.RoutingPolicies.SingleOrDefault( + policy => string.Equals(policy.Name, this.Name, StringComparison.CurrentCultureIgnoreCase)); + if (existingRoutingPolicy != null) + { + throw new ArgumentException("RoutingPolicy with specified name already exists"); + } + + if (this.RoutingIntent.RoutingPolicies == null) + { + this.RoutingIntent.RoutingPolicies = new List(); + } + + var routingPolicy = new PSRoutingPolicy + { + Name = this.Name, + Destinations = this.Destination?.ToList(), + NextHop = this.NextHop, + }; + this.RoutingIntent.RoutingPolicies.Add(routingPolicy); + WriteObject(this.RoutingIntent); + } + } +} diff --git a/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/GetAzureRmRoutingPolicyCommand.cs b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/GetAzureRmRoutingPolicyCommand.cs new file mode 100644 index 000000000000..8ca07da2ad1a --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/GetAzureRmRoutingPolicyCommand.cs @@ -0,0 +1,58 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System; + using System.Linq; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + + [Cmdlet( + VerbsCommon.Get, + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingPolicy", + SupportsShouldProcess = false), + OutputType(typeof(PSRoutingPolicy))] + public class GetAzureRmRoutingPolicyCommand : NetworkBaseCmdlet + { + [Parameter( + Mandatory = true, + HelpMessage = "The reference of the routing intent resource.", + ValueFromPipeline = true, + ValueFromPipelineByPropertyName = true)] + public PSRoutingIntent RoutingIntent { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The unique name for this routing policy.")] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + public override void Execute() + { + base.Execute(); + if(!string.IsNullOrWhiteSpace(this.Name)) + { + + var routingPolicy = this.RoutingIntent.RoutingPolicies.SingleOrDefault( + policy => string.Equals(policy.Name, this.Name, StringComparison.CurrentCultureIgnoreCase)); + WriteObject(routingPolicy); + } + else + { + throw new ArgumentException("The routing policy with given name does not exist."); + } + } + } +} diff --git a/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/NewAzureRmRoutingPolicyCommand.cs b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/NewAzureRmRoutingPolicyCommand.cs new file mode 100644 index 000000000000..f366f80e20ca --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/NewAzureRmRoutingPolicyCommand.cs @@ -0,0 +1,60 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System.Linq; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + + [Cmdlet( + VerbsCommon.New, + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingPolicy", + SupportsShouldProcess = false), + OutputType(typeof(PSRoutingPolicy))] + public class NewAzureRmRoutingPolicyCommand : NetworkBaseCmdlet + { + [Parameter( + Mandatory = true, + HelpMessage = "List of all destinations which this routing policy is applicable to (for example: Internet, PrivateTraffic).")] + [ValidateNotNullOrEmpty] + public string[] Destination { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The next hop resource id on which this routing policy is applicable to.")] + [ValidateNotNullOrEmpty] + public string NextHop { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The unique name for this routing policy.")] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + public override void Execute() + { + base.Execute(); + + var routingPolicy = new PSRoutingPolicy + { + Name = this.Name, + Destinations = this.Destination?.ToList(), + NextHop = this.NextHop, + }; + + WriteObject(routingPolicy); + } + } +} diff --git a/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/RemoveAzureRmRoutingPolicyCommand.cs b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/RemoveAzureRmRoutingPolicyCommand.cs new file mode 100644 index 000000000000..e5b6c31c5fd8 --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/RemoveAzureRmRoutingPolicyCommand.cs @@ -0,0 +1,66 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System; + using System.Linq; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + + [Cmdlet( + VerbsCommon.Remove, + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingPolicy", + SupportsShouldProcess = false), + OutputType(typeof(PSRoutingIntent))] + public class RemoveAzureRmRoutingPolicyCommand : NetworkBaseCmdlet + { + [Parameter( + Mandatory = true, + HelpMessage = "The reference of the routing intent resource.", + ValueFromPipeline = true, + ValueFromPipelineByPropertyName = true)] + public PSRoutingIntent RoutingIntent { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The unique name for this routing policy.")] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + public override void Execute() + { + if (this.RoutingIntent.RoutingPolicies == null || !this.RoutingIntent.RoutingPolicies.Any()) + { + WriteObject(this.RoutingIntent); + return; + } + + var routingPolicyToRemove = this.RoutingIntent.RoutingPolicies.SingleOrDefault( + policy => string.Equals(policy.Name, this.Name, StringComparison.CurrentCultureIgnoreCase)); + + if (routingPolicyToRemove != null) + { + this.RoutingIntent.RoutingPolicies.Remove(routingPolicyToRemove); + } + + if(this.RoutingIntent.RoutingPolicies.Count == 0) + { + this.RoutingIntent.RoutingPolicies = null; + } + + WriteObject(this.RoutingIntent); + } + } +} diff --git a/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/SetAzureRmRoutingPolicyCommand.cs b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/SetAzureRmRoutingPolicyCommand.cs new file mode 100644 index 000000000000..ffa7d2fca483 --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/RoutingPolicy/SetAzureRmRoutingPolicyCommand.cs @@ -0,0 +1,77 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System; + using System.Linq; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + + [Cmdlet( + VerbsCommon.Set, + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingPolicy", + SupportsShouldProcess = false), + OutputType(typeof(PSRoutingIntent))] + public class SetAzureRmRoutingPolicyCommand : NetworkBaseCmdlet + { + [Parameter( + Mandatory = true, + HelpMessage = "The reference of the routing intent resource.", + ValueFromPipeline = true, + ValueFromPipelineByPropertyName = true)] + public PSRoutingIntent RoutingIntent { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "List of all destinations which this routing policy is applicable to (for example: Internet, PrivateTraffic).")] + [ValidateNotNullOrEmpty] + public string[] Destination { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The next hop resource id on which this routing policy is applicable to.")] + [ValidateNotNullOrEmpty] + public string NextHop { get; set; } + + [Parameter( + Mandatory = true, + HelpMessage = "The unique name for this routing policy.")] + [ValidateNotNullOrEmpty] + public string Name { get; set; } + + public override void Execute() + { + base.Execute(); + var routingPolicyIndex = this.RoutingIntent.RoutingPolicies.IndexOf( + this.RoutingIntent.RoutingPolicies.SingleOrDefault( + policy => string.Equals(policy.Name, this.Name, StringComparison.CurrentCultureIgnoreCase))); + + if(routingPolicyIndex == -1) + { + throw new ArgumentException("RoutingPolicy with specified name does not exist"); + } + + var routingPolicy = new PSRoutingPolicy + { + Name = this.Name, + Destinations = this.Destination?.ToList(), + NextHop = this.NextHop, + }; + this.RoutingIntent.RoutingPolicies[routingPolicyIndex] = routingPolicy; + + WriteObject(this.RoutingIntent); + } + } +} diff --git a/src/Network/Network/Cortex/RoutingIntent/SetAzureRmRoutingIntentCommand.cs b/src/Network/Network/Cortex/RoutingIntent/SetAzureRmRoutingIntentCommand.cs new file mode 100644 index 000000000000..ba2ae5b8afd0 --- /dev/null +++ b/src/Network/Network/Cortex/RoutingIntent/SetAzureRmRoutingIntentCommand.cs @@ -0,0 +1,158 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network +{ + using System; + using System.Linq; + using System.Management.Automation; + using Microsoft.Azure.Commands.Network.Models; + using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters; + using Microsoft.Azure.Management.Internal.Resources.Utilities.Models; + + [Cmdlet("Set", + ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "RoutingIntent", + DefaultParameterSetName = CortexParameterSetNames.ByRoutingIntentName, + SupportsShouldProcess = true), + OutputType(typeof(PSRoutingIntent))] + public class SetAzureRmRoutingIntentCommand : RoutingIntentBaseCmdlet + { + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentName, + HelpMessage = "The resource group name.")] + [ResourceGroupCompleter] + [ValidateNotNullOrEmpty] + public string ResourceGroupName { get; set; } + + [Alias("VirtualHubName", "ParentVirtualHubName")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentName, + HelpMessage = "The resource group name.")] + public string ParentResourceName { get; set; } + + [Alias("ResourceName", "RoutingIntentName", "RouteTableName")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentName, + HelpMessage = "Name of the route table.")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubObject, + HelpMessage = "Name of the route table.")] + public string Name { get; set; } + + [Alias("VirtualHub", "ParentVirtualHub")] + [Parameter( + Mandatory = true, + ParameterSetName = CortexParameterSetNames.ByVirtualHubObject, + HelpMessage = "The parent virtual hub object.")] + public PSVirtualHub ParentObject { get; set; } + + [Alias("RoutingIntent")] + [Parameter( + Mandatory = true, + ValueFromPipeline = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentObject, + HelpMessage = "The routing intent resource to modify.")] + public PSRoutingIntent InputObject { get; set; } + + [Alias("RoutingIntentId")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = CortexParameterSetNames.ByRoutingIntentResourceId, + HelpMessage = "The resource id of the routing intent to modify.")] + [ResourceIdCompleter("Microsoft.Network/virtualHubs/routingIntent")] + public string ResourceId { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "The list of routing policies for this routing intent resource.")] + public PSRoutingPolicy[] RoutingPolicy { get; set; } + + [Parameter( + Mandatory = false, + HelpMessage = "Run cmdlet in the background")] + public SwitchParameter AsJob { get; set; } + + public override void Execute() + { + base.Execute(); + PSRoutingIntent routingIntentToUpdate = null; + if (ParameterSetName.Equals(CortexParameterSetNames.ByRoutingIntentObject, StringComparison.OrdinalIgnoreCase)) + { + routingIntentToUpdate = this.InputObject; + this.ResourceId = this.InputObject.Id; + if (string.IsNullOrWhiteSpace(this.ResourceId)) + { + throw new PSArgumentException(Properties.Resources.RoutingIntentNotFound); + } + + var parsedResourceId = new ResourceIdentifier(this.ResourceId); + this.ResourceGroupName = parsedResourceId.ResourceGroupName; + this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); + this.Name = parsedResourceId.ResourceName; + } + else + { + if (ParameterSetName.Equals(CortexParameterSetNames.ByRoutingIntentResourceId, StringComparison.OrdinalIgnoreCase)) + { + var parsedResourceId = new ResourceIdentifier(this.ResourceId); + this.ResourceGroupName = parsedResourceId.ResourceGroupName; + this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last(); + this.Name = parsedResourceId.ResourceName; + } + else if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualHubObject, StringComparison.OrdinalIgnoreCase)) + { + var parentResourceId = this.ParentObject.Id; + var parsedParentResourceId = new ResourceIdentifier(parentResourceId); + this.ResourceGroupName = parsedParentResourceId.ResourceGroupName; + this.ParentResourceName = parsedParentResourceId.ResourceName; + } + + try + { + routingIntentToUpdate = this.GetRoutingIntent(this.ResourceGroupName, this.ParentResourceName, this.Name); + } + catch (Exception ex) + { + if (ex is Microsoft.Azure.Management.Network.Models.ErrorException || ex is Rest.Azure.CloudException) + { + throw new PSArgumentException(Properties.Resources.RoutingIntentNotFound); + } + throw; + } + } + + // this will thorw if hub does not exist. + IsParentVirtualHubPresent(this.ResourceGroupName, this.ParentResourceName); + + if (this.RoutingPolicy != null) + { + routingIntentToUpdate.RoutingPolicies = this.RoutingPolicy.ToList(); + } + + ConfirmAction( + Properties.Resources.SettingResourceMessage, + this.Name, + () => + { + WriteVerbose(String.Format(Properties.Resources.CreatingLongRunningOperationMessage, this.ResourceGroupName, this.Name)); + WriteObject(this.CreateOrUpdateRoutingIntent(this.ResourceGroupName, this.ParentResourceName, this.Name, routingIntentToUpdate)); + }); + } + } +} diff --git a/src/Network/Network/Models/Cortex/PSRoutingIntent.cs b/src/Network/Network/Models/Cortex/PSRoutingIntent.cs new file mode 100644 index 000000000000..e7ac68888854 --- /dev/null +++ b/src/Network/Network/Models/Cortex/PSRoutingIntent.cs @@ -0,0 +1,46 @@ +// ---------------------------------------------------------------------------------- +// +// Copyright Microsoft Corporation +// 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. +// ---------------------------------------------------------------------------------- + +namespace Microsoft.Azure.Commands.Network.Models +{ + using System.Collections.Generic; + using Microsoft.WindowsAzure.Commands.Common.Attributes; + using Newtonsoft.Json; + + public class PSRoutingIntent : PSChildResource + { + [Ps1Xml(Label = "Provisioning State", Target = ViewControl.Table)] + public string ProvisioningState { get; set; } + + public List RoutingPolicies { get; set; } + + [JsonIgnore] + public string RoutingPoliciesText + { + get { return JsonConvert.SerializeObject(RoutingPolicies, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); } + } + } + + public class PSRoutingPolicy + { + [Ps1Xml(Label = "Name", Target = ViewControl.Table)] + public string Name { get; set; } + + [Ps1Xml(Label = "Destinations", Target = ViewControl.Table)] + public List Destinations { get; set; } + + [Ps1Xml(Label = "Next Hop", Target = ViewControl.Table)] + public string NextHop { get; set; } + } +} diff --git a/src/Network/Network/Network.format.ps1xml b/src/Network/Network/Network.format.ps1xml index 94e80d865f2e..c3d91d79296a 100644 --- a/src/Network/Network/Network.format.ps1xml +++ b/src/Network/Network/Network.format.ps1xml @@ -6907,5 +6907,35 @@ + + Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + + Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + + + + + + + + Name + + + + Id + + + + ProvisioningState + + + + RoutingPoliciesText + + + + + + diff --git a/src/Network/Network/Properties/Resources.Designer.cs b/src/Network/Network/Properties/Resources.Designer.cs index 516876cf79bb..49e88cb3530e 100644 --- a/src/Network/Network/Properties/Resources.Designer.cs +++ b/src/Network/Network/Properties/Resources.Designer.cs @@ -1162,6 +1162,15 @@ internal static string RemoveRouteServerWarning { } } + /// + /// Looks up a localized string similar to Removing this Routing Intent resource will remove all routing policies present in this and may affect the routing in your VirtualHub. + /// + internal static string RemoveRoutingIntentWarning { + get { + return ResourceManager.GetString("RemoveRoutingIntentWarning", resourceCulture); + } + } + /// /// Looks up a localized string similar to Removing this HubRouteTable will remove all routes present in this and may affect the routing in your VirtualHub.. /// @@ -1297,6 +1306,15 @@ internal static string RouteTableNotFound { } } + /// + /// Looks up a localized string similar to The routing intent resource could not be found. + /// + internal static string RoutingIntentNotFound { + get { + return ResourceManager.GetString("RoutingIntentNotFound", resourceCulture); + } + } + /// /// Looks up a localized string similar to SetByFqdn. /// diff --git a/src/Network/Network/Properties/Resources.resx b/src/Network/Network/Properties/Resources.resx index b4cb10471218..78ba8aafac56 100644 --- a/src/Network/Network/Properties/Resources.resx +++ b/src/Network/Network/Properties/Resources.resx @@ -735,4 +735,10 @@ The VirtualNetworkGatewayNatRule could not be found + + Removing this Routing Intent resource will remove all routing policies present in this and may affect the routing in your VirtualHub + + + The routing intent resource could not be found + \ No newline at end of file diff --git a/src/Network/Network/help/Add-AzRoutingPolicy.md b/src/Network/Network/help/Add-AzRoutingPolicy.md new file mode 100644 index 000000000000..2da03bf2a681 --- /dev/null +++ b/src/Network/Network/help/Add-AzRoutingPolicy.md @@ -0,0 +1,202 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/add-azroutingpolicy +schema: 2.0.0 +--- + +# Add-AzRoutingPolicy + +## SYNOPSIS +Add a Routing Policy to the Routing Intent object. + +## SYNTAX + +### (Default) +``` +Add-AzRoutingPolicy -RoutingIntent -Name -Destination -NextHop + [-Force] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +The **Add-AzRoutingPolicy** cmdlet adds a RoutingPolicy to a RoutingIntent resource. This will only return an updated in-memory routing intent resource. Please use the [Set-AzRoutingIntent](./Set-AzRoutingIntent.md) cmdlet to update the actual resource and ensure that the policies take effect. + +## EXAMPLES + +### Example 1 +```powershell +$rgName = "testRg" +$firewallName = "testFirewall" +$firewall = Get-AzFirewall -Name $firewallName -ResourceGroupName $rgName +$routingIntent = Get-AzRoutingIntent -Name "routingIntent1" -HubName "hub1" -ResourceGroupName $rgName +Add-AzRoutingPolicy -Name "privateTrafficPolicy" -RoutingIntent $routingIntent -Destination @("10.0.0.0/8", "192.168.0.0/16") -NextHop $firewall.Id +``` + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Force +Do not ask for confirmation if you want to overwrite a resource + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +Name of the routing policy + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -NextHop +Id of the next hop resource. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Destination +The list of destinations. + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: ResourceName + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -RoutingIntent +The routing intent resource to which this rouing policy has to be added. + +```yaml +Type: Microsoft.Azure.Commands.Network.Models.PSRoutingIntent +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## NOTES + +## RELATED LINKS + +[Get-AzRoutingIntent](./Get-AzRoutingIntent.md) + +[Get-AzRoutingPolicy](./Get-AzRoutingPolicy.md) + +[New-AzRoutingPolicy](./New-AzRoutingPolicy.md) + +[Remove-AzRoutingIntent](./Remove-AzRoutingIntent.md) + +[Remove-AzRoutingPolicy](./Remove-AzRoutingPolicy.md) + +[Set-AzRoutingIntent](./Set-AzRoutingIntent.md) + +[Set-AzRoutingPolicy](./Set-AzRoutingPolicy.md) \ No newline at end of file diff --git a/src/Network/Network/help/Get-AzRoutingIntent.md b/src/Network/Network/help/Get-AzRoutingIntent.md new file mode 100644 index 000000000000..5f8f91f873b6 --- /dev/null +++ b/src/Network/Network/help/Get-AzRoutingIntent.md @@ -0,0 +1,264 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/get-azroutingintent +schema: 2.0.0 +--- + +# Get-AzRoutingIntent + +## SYNOPSIS +Retrieves a routing intent resource associated with a VirtualHub. + +## SYNTAX + +### ByRoutingIntentName (Default) +```powershell +Get-AzRoutingIntent -ResourceGroupName -ParentResourceName -Name [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByVirtualHubObject +```powershell +Get-AzRoutingIntent -Name -VirtualHub [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByRoutingIntentResourceId +```powershell +Get-AzRoutingIntent -ResourceId [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Gets the specified routing intent that is associated with the specified virtual hub. + +## EXAMPLES + +### Example 1 + +```powershell +New-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" -Location "westcentralus" -VirtualWANType "Standard" -AllowVnetToVnetTraffic -AllowBranchToBranchTraffic +$virtualWan = Get-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" +New-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" -Location "westcentralus" -AddressPrefix "10.0.0.0/16" -VirtualWan $virtualWan +$virtualHub = Get-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" +$fwIp = New-AzFirewallHubPublicIpAddress -Count 1 +$hubIpAddresses = New-AzFirewallHubIpAddress -PublicIP $fwIp +New-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" -Location "westcentralus" -Sku AZFW_Hub -VirtualHubId $virtualHub.Id -HubIPAddress $hubIpAddresses +$firewall = Get-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" +$route1 = New-AzVHubRoute -Name "private-traffic" -Destination @("10.30.0.0/16", "10.40.0.0/16") -DestinationType "CIDR" -NextHop $firewall.Id -NextHopType "ResourceId" +New-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" -Route @($route1) -Label @("testLabel") +Get-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" +``` + +```output +Name : testRoutingIntent +Id : /subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/testHub/hubRouteTables/testRoutingIntent +ProvisioningState : Succeeded +Labels : {testLabel} +Routes : [ + { + "Name": "private-traffic", + "DestinationType": "CIDR", + "Destinations": [ + "10.30.0.0/16", + "10.40.0.0/16" + ], + "NextHopType": "ResourceId", + "NextHop": "/subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/azureFirewalls/testFirewall" + } + ] +AssociatedConnections : [] +PropagatingConnections : [] +``` + +This command gets the hub route table of the virtual hub. + +### Example 2 + +```powershell +$rgName = "testRg" +$virtualHubName = "testHub" +Get-AzRoutingIntent -ResourceGroupName $rgName -VirtualHubName $virtualHubName +``` + +```output +Name : defaultRouteTable +Id : /subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/testHub/hubRouteTables/defaultRouteTable +ProvisioningState : Succeeded +Labels : {testLabel} +Routes : [] +AssociatedConnections : [] +PropagatingConnections : [] + + +Name : noneRouteTable +Id : /subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/testHub/hubRouteTables/noneRouteTable +ProvisioningState : Succeeded +Labels : {testLabel} +Routes : [] +AssociatedConnections : [] +PropagatingConnections : [] +``` + +This command lists all the hub route tables in the specified VirtualHub. + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The resource name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName, ByVirtualHubObject +Aliases: ResourceName, RoutingIntentName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ParentObject +The parent virtual hub object of this resource. + +```yaml +Type: PSVirtualHub +Parameter Sets: ByVirtualHubObject +Aliases: ParentVirtualHub, VirtualHub + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -ParentResourceName +The parent resource name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName +Aliases: VirtualHubName, ParentVirtualHubName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceGroupName +The resource group name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceId +The resource id of the RoutingIntent resource to Get. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentResourceId +Aliases: RoutingIntentId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.Commands.Network.Models.PSVirtualHub + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## NOTES + +## RELATED LINKS + +[New-AzVHubRoute](./New-AzVHubRoute.md) + +[New-AzRoutingIntent](./New-AzRoutingIntent.md) + +[Update-AzRoutingIntent](./Update-AzRoutingIntent.md) + +[Remove-AzRoutingIntent](./Remove-AzRoutingIntent.md) \ No newline at end of file diff --git a/src/Network/Network/help/Get-AzRoutingPolicy.md b/src/Network/Network/help/Get-AzRoutingPolicy.md new file mode 100644 index 000000000000..0a53b44bb751 --- /dev/null +++ b/src/Network/Network/help/Get-AzRoutingPolicy.md @@ -0,0 +1,167 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/get-azroutingpolicy +schema: 2.0.0 +--- + +# Get-AzRoutingPolicy + +## SYNOPSIS +Retrieves a routing policy of a routing intent resource associated with a VirtualHub. + +## SYNTAX + +### ByRoutingIntentObject +```powershell +Get-AzRoutingPolicy -Name -RoutingIntent [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Gets the specified routing Policy that is associated with the specified routing intent resource. + +## EXAMPLES + +### Example 1 + +```powershell +New-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" -Location "westcentralus" -VirtualWANType "Standard" -AllowVnetToVnetTraffic -AllowBranchToBranchTraffic +$virtualWan = Get-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" +New-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" -Location "westcentralus" -AddressPrefix "10.0.0.0/16" -VirtualWan $virtualWan +$virtualHub = Get-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" +$fwIp = New-AzFirewallHubPublicIpAddress -Count 1 +$hubIpAddresses = New-AzFirewallHubIpAddress -PublicIP $fwIp +New-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" -Location "westcentralus" -Sku AZFW_Hub -VirtualHubId $virtualHub.Id -HubIPAddress $hubIpAddresses +$firewall = Get-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" +$policy1 = New-AzRoutingPolicy -Name "private-traffic-policy" -Destination @("10.30.0.0/16", "10.40.0.0/16") -NextHop $firewall.Id +New-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" -RoutingPolicy @($policy1) +$routingIntent = Get-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" +Get-AzRoutingPolicy -RoutingIntent $routingIntent -Name "private-traffic-policy" +``` + +```output +Name : private-traffic-policy +Destinations : [ + "10.30.0.0/16", + "10.40.0.0/16" + ] +NextHop : "/subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/azureFirewalls/testFirewall" +``` + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The policy name. + +```yaml +Type: String +Parameter Sets: ByRoutingPolicyName, ByVirtualHubObject +Aliases: ResourceName, RoutingPolicyName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RoutingIntent +The routing intent resource to which this rouing policy has to be added. + +```yaml +Type: Microsoft.Azure.Commands.Network.Models.PSRoutingIntent +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingPolicy + +## NOTES + +## RELATED LINKS + +[New-AzRoutingPolicy](./New-AzRoutingPolicy.md) + +[New-AzRoutingPolicy](./New-AzRoutingPolicy.md) + +[Set-AzRoutingPolicy](./Set-AzRoutingPolicy.md) + +[Remove-AzRoutingPolicy](./Remove-AzRoutingPolicy.md) \ No newline at end of file diff --git a/src/Network/Network/help/New-AzRoutingIntent.md b/src/Network/Network/help/New-AzRoutingIntent.md new file mode 100644 index 000000000000..4362104f0231 --- /dev/null +++ b/src/Network/Network/help/New-AzRoutingIntent.md @@ -0,0 +1,266 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/new-azroutingintent +schema: 2.0.0 +--- + +# New-AzRoutingIntent + +## SYNOPSIS +Creates a routing intent resource associated with a VirtualHub. + +## SYNTAX + +### ByVirtualHubName (Default) + +```powershell +New-AzRoutingIntent -ResourceGroupName -ParentResourceName -Name -RoutingPolicy [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByVirtualHubObject + +```powershell +New-AzRoutingIntent -Name -ParentObject -RoutingPolicy [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByVirtualHubResourceId + +```powershell +New-AzRoutingIntent -ParentResourceId -Name -RoutingPolicy [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Creates the specified routing intent that is associated with the specified virtual hub with the provided list of routing policies. + +## EXAMPLES + +### Example 1 + +```powershell +New-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" -Location "westcentralus" -VirtualWANType "Standard" -AllowVnetToVnetTraffic -AllowBranchToBranchTraffic +$virtualWan = Get-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" + +New-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" -Location "westcentralus" -AddressPrefix "10.0.0.0/16" -VirtualWan $virtualWan +$virtualHub = Get-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" + +$fwIp = New-AzFirewallHubPublicIpAddress -Count 1 +$hubIpAddresses = New-AzFirewallHubIpAddress -PublicIP $fwIp +New-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" -Location "westcentralus" -Sku AZFW_Hub -VirtualHubId $virtualHub.Id -HubIPAddress $hubIpAddresses +$firewall = Get-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" + +$routingPolicy1 = New-AzRoutingPolicy -Name "private-traffic-policy" -Destination @("10.30.0.0/16", "10.40.0.0/16") -NextHop $firewall.Id +$routingPolicy2 = New-AzRoutingPolicy -Name "internet-traffic-policy" -Destination @("0.0.0.0/0") -NextHop $firewall.Id +New-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" -RoutingPolicy @($routingPolicy1, $routingPolicy2) +``` + +```output +Name : testRoutingIntent +Id : /subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/testHub/hubRouteTables/testRoutingIntent +ProvisioningState : Succeeded +Labels : {testLabel} +Routes : [ + { + "Name": "private-traffic", + "DestinationType": "CIDR", + "Destinations": [ + "10.30.0.0/16", + "10.40.0.0/16" + ], + "NextHopType": "ResourceId", + "NextHop": "/subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/azureFirewalls/testFirewall" + } + ] +AssociatedConnections : [] +PropagatingConnections : [] +``` + +This command creates a routing intent of the virtual hub. + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The resource name. + +```yaml +Type: String +Parameter Sets: (All) +Aliases: ResourceName, RoutingIntentName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ParentObject +The parent virtual hub object of this resource. + +```yaml +Type: PSVirtualHub +Parameter Sets: ByVirtualHubObject +Aliases: ParentVirtualHub, VirtualHub + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -ParentResourceName +The parent resource name. + +```yaml +Type: String +Parameter Sets: ByVirtualHubName +Aliases: VirtualHubName, ParentVirtualHubName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceGroupName +The resource group name. + +```yaml +Type: String +Parameter Sets: ByVirtualHubName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ParentResourceId +The resource id of the virtual hub resource. + +```yaml +Type: String +Parameter Sets: ByVirtualHubResourceId +Aliases: VirtualHubId, ParentVirtualHubId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -RoutingPolicy +The list of routing policies for this rouoting intent resource. + +```yaml +Type: PSRoutingPolicy[] +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.Commands.Network.Models.PSVirtualHub + +### Microsoft.Azure.Commands.Network.Models.PSRoutingPolicy + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## NOTES + +## RELATED LINKS + +[Add-AzRoutingPolicy](./Add-AzRoutingPolicy.md) + +[Get-AzRoutingIntent](./Get-AzRoutingIntent.md) + +[Get-AzRoutingPolicy](./Get-AzRoutingPolicy.md) + +[New-AzRoutingPolicy](./New-AzRoutingPolicy.md) + +[Remove-AzRoutingIntent](./Remove-AzRoutingIntent.md) + +[Remove-AzRoutingPolicy](./Remove-AzRoutingPolicy.md) + +[Set-AzRoutingIntent](./Set-AzRoutingIntent.md) + +[Set-AzRoutingPolicy](./Set-AzRoutingPolicy.md) diff --git a/src/Network/Network/help/New-AzRoutingPolicy.md b/src/Network/Network/help/New-AzRoutingPolicy.md new file mode 100644 index 000000000000..6d722f61047c --- /dev/null +++ b/src/Network/Network/help/New-AzRoutingPolicy.md @@ -0,0 +1,198 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/new-azroutingpolicy +schema: 2.0.0 +--- + +# New-AzRoutingPolicy + +## SYNOPSIS +Returns an in-memory routing policy object. + +## SYNTAX + +### (Default) +``` +New-AzRoutingPolicy -Name -Destination -NextHop + [-Force] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +The **New-AzRoutingPolicy** cmdlet creates a routing policy object. This can be passed in to [Add-AzRoutingPolicy](./Add-AzRoutingPolicy.md) cmdlet to add to an existing routing intent resource or [New-AzRoutingIntent](./New-AzRoutingIntent.md) cmdlet to create a new routing intent resource. + +## EXAMPLES + +### Example 1 +```powershell +$rgName = "testRg" +$firewallName = "testFirewall" +$firewall = Get-AzFirewall -Name $firewallName -ResourceGroupName $rgName +$policy1 = New-AzRoutingPolicy -Name "privateTrafficPolicy" -Destination @("10.0.0.0/8", "192.168.0.0/16") -NextHop $firewall.Id +$policy1 +``` + +```output +Name : private-traffic-policy +Destinations : [ + "10.30.0.0/16", + "10.40.0.0/16" + ] +NextHop : "/subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/azureFirewalls/testFirewall" +``` + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Force +Do not ask for confirmation if you want to overwrite a resource + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +Name of the routing policy + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -NextHop +Id of the next hop resource. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Destination +The list of destinations. + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: ResourceName + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingPolicy + +## NOTES + +## RELATED LINKS + +[Add-AzRoutingPolicy](./Add-AzRoutingPolicy.md) + +[Get-AzRoutingIntent](./Get-AzRoutingIntent.md) + +[Get-AzRoutingPolicy](./Get-AzRoutingPolicy.md) + +[New-AzRoutingIntent](./New-AzRoutingIntent.md) + +[Remove-AzRoutingIntent](./Remove-AzRoutingIntent.md) + +[Remove-AzRoutingPolicy](./Remove-AzRoutingPolicy.md) + +[Set-AzRoutingIntent](./Set-AzRoutingIntent.md) + +[Set-AzRoutingPolicy](./Set-AzRoutingPolicy.md) \ No newline at end of file diff --git a/src/Network/Network/help/Remove-AzRoutingIntent.md b/src/Network/Network/help/Remove-AzRoutingIntent.md new file mode 100644 index 000000000000..199d501382dc --- /dev/null +++ b/src/Network/Network/help/Remove-AzRoutingIntent.md @@ -0,0 +1,254 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/remove-azroutingintent +schema: 2.0.0 +--- + +# Remove-AzRoutingIntent + +## SYNOPSIS +Delete a routing intent resource associated with a VirtualHub. + +## SYNTAX + +### ByRoutingIntentName (Default) +```powershell +Remove-AzRoutingIntent -ResourceGroupName -ParentResourceName -Name [-AsJob] [-Force] [-PassThru] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByVirtualHubObject +```powershell +Remove-AzRoutingIntent -Name -VirtualHub [-AsJob] [-Force] [-PassThru] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByRoutingIntentObject +```powershell +Remove-AzRoutingIntent [-InputObject ] [-AsJob] [-Force] [-PassThru] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByRoutingIntentResourceId +```powershell +Remove-AzRoutingIntent -ResourceId [-AsJob] [-Force] [-PassThru] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Deletes the specified routing intent that is associated with the specified virtual hub. + +## EXAMPLES + +### Example 1 +```powershell +$testRoutingIntent = Get-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" +Remove-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" +``` + +This command deletes the routing intent of the virtual hub. + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Force +Do not ask for confirmation if you want to overwrite a resource + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +The RoutingIntent resource to remove. + +```yaml +Type: PSRoutingIntent +Parameter Sets: ByRoutingIntentObject +Aliases: RoutingIntent + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Name +The resource name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName, ByVirtualHubObject +Aliases: ResourceName, RoutingIntentName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ParentObject +The parent virtual hub object of this resource. + +```yaml +Type: PSVirtualHub +Parameter Sets: ByVirtualHubObject +Aliases: ParentVirtualHub, VirtualHub + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -ParentResourceName +The parent resource name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName +Aliases: VirtualHubName, ParentVirtualHubName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -PassThru +Returns an object representing the item on which this operation is being performed. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceGroupName +The resource group name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceId +The resource id of the RoutingIntent resource to remove. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentResourceId +Aliases: RoutingIntentId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.Commands.Network.Models.PSVirtualHub + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +### System.String + +## OUTPUTS + +### System.Boolean + +## NOTES + +## RELATED LINKS + +[Get-AzRoutingIntent](./Get-AzRoutingIntent.md) + +[New-AzRoutingIntent](./New-AzRoutingIntent.md) + +[Set-AzRoutingIntent](./Set-AzRoutingIntent.md) \ No newline at end of file diff --git a/src/Network/Network/help/Remove-AzRoutingPolicy.md b/src/Network/Network/help/Remove-AzRoutingPolicy.md new file mode 100644 index 000000000000..52c450ba7400 --- /dev/null +++ b/src/Network/Network/help/Remove-AzRoutingPolicy.md @@ -0,0 +1,175 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/remove-azroutingpolicy +schema: 2.0.0 +--- + +# Remove-AzRoutingPolicy + +## SYNOPSIS +Removes the specified routing policy from a routing intent resource associated with a VirtualHub. + +## SYNTAX + +### ByRoutingIntentObject +```powershell +Remove-AzRoutingPolicy -Name -RoutingIntent [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Removes the specified routing Policy that is associated with the specified routing intent object and returns an in-memory routing intent object which can be piped to [Set-AzRoutingIntent](./Set-AzRoutingIntent.md) to update the actual routing intent resource. + +## EXAMPLES + +### Example 1 + +```powershell +New-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" -Location "westcentralus" -VirtualWANType "Standard" -AllowVnetToVnetTraffic -AllowBranchToBranchTraffic +$virtualWan = Get-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" +New-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" -Location "westcentralus" -AddressPrefix "10.0.0.0/16" -VirtualWan $virtualWan +$virtualHub = Get-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" +$fwIp = New-AzFirewallHubPublicIpAddress -Count 1 +$hubIpAddresses = New-AzFirewallHubIpAddress -PublicIP $fwIp +New-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" -Location "westcentralus" -Sku AZFW_Hub -VirtualHubId $virtualHub.Id -HubIPAddress $hubIpAddresses +$firewall = Get-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" +$policy1 = New-AzRoutingPolicy -Name "private-traffic-policy" -Destination @("10.30.0.0/16", "10.40.0.0/16") -NextHop $firewall.Id +New-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" -RoutingPolicy @($policy1) +$routingIntent = Get-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingIntent" +Remove-AzRoutingPolicy -RoutingIntent $routingIntent -Name "private-traffic-policy" +``` + +```output +Name : private-traffic-policy +Destinations : [ + "10.30.0.0/16", + "10.40.0.0/16" + ] +NextHop : "/subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/azureFirewalls/testFirewall" +``` + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +The policy name. + +```yaml +Type: String +Parameter Sets: ByRoutingPolicyName, ByVirtualHubObject +Aliases: ResourceName, RoutingPolicyName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -RoutingIntent +The routing intent object from which this rouing policy has to be removed. + +```yaml +Type: Microsoft.Azure.Commands.Network.Models.PSRoutingIntent +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## NOTES + +## RELATED LINKS + +[Add-AzRoutingPolicy](./Add-AzRoutingPolicy.md) + +[Get-AzRoutingIntent](./Get-AzRoutingIntent.md) + +[Get-AzRoutingPolicy](./Get-AzRoutingPolicy.md) + +[New-AzRoutingIntent](./New-AzRoutingIntent.md) + +[New-AzRoutingPolicy](./New-AzRoutingPolicy.md) + +[Remove-AzRoutingIntent](./Remove-AzRoutingIntent.md) + +[Set-AzRoutingIntent](./Set-AzRoutingIntent.md) + +[Set-AzRoutingPolicy](./Set-AzRoutingPolicy.md) \ No newline at end of file diff --git a/src/Network/Network/help/Set-AzRoutingIntent.md b/src/Network/Network/help/Set-AzRoutingIntent.md new file mode 100644 index 000000000000..74ae0a9b2e9e --- /dev/null +++ b/src/Network/Network/help/Set-AzRoutingIntent.md @@ -0,0 +1,285 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/set-azroutingintent +schema: 2.0.0 +--- + +# Set-AzRoutingIntent + +## SYNOPSIS +Updates a routing intent resource associated with a VirtualHub. + +## SYNTAX + +### ByRoutingIntentName (Default) +```powershell +Set-AzRoutingIntent -ResourceGroupName -ParentResourceName -Name [-RoutingPolicy ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByVirtualHubObject +```powershell +Set-AzRoutingIntent -Name -ParentObject [-RoutingPolicy ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByRoutingIntentObject +```powershell +Set-AzRoutingIntent -InputObject [-RoutingPolicy ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +### ByRoutingIntentResourceId +```powershell +Set-AzRoutingIntent -ResourceId [-RoutingPolicy ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +Updates the specified routing intent that is associated with the specified virtual hub. If a list of routing policies is provided, these will overwrite the existing policies on the current routing intent resource. + +## EXAMPLES + +### Example 1 +```powershell +New-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" -Location "westcentralus" -VirtualWANType "Standard" -AllowVnetToVnetTraffic -AllowBranchToBranchTraffic +$virtualWan = Get-AzVirtualWan -ResourceGroupName "testRg" -Name "testWan" + +New-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" -Location "westcentralus" -AddressPrefix "10.0.0.0/16" -VirtualWan $virtualWan +$virtualHub = Get-AzVirtualHub -ResourceGroupName "testRg" -Name "testHub" + +$fwIp = New-AzFirewallHubPublicIpAddress -Count 1 +$hubIpAddresses = New-AzFirewallHubIpAddress -PublicIP $fwIp +New-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" -Location "westcentralus" -Sku AZFW_Hub -VirtualHubId $virtualHub.Id -HubIPAddress $hubIpAddresses +$firewall = Get-AzFirewall -Name "testFirewall" -ResourceGroupName "testRg" + +$RoutingPolicy1 = New-AzVHubRoutingPolicy -Name "private-traffic-policy" -Destination @("10.30.0.0/16", "10.40.0.0/16") -NextHop $firewall.Id +New-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingPolicyTable" -RoutingPolicy @($RoutingPolicy1) +Get-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingPolicyTable" + +$RoutingPolicy2 = New-AzVHubRoutingPolicy -Name "internet-traffic-policy" -Destination @("0.0.0.0/0") -NextHop $firewall.Id +Set-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingPolicyTable" -RoutingPolicy @($RoutingPolicy2) +Get-AzRoutingIntent -ResourceGroupName "testRg" -VirtualHubName "testHub" -Name "testRoutingPolicyTable" +``` + +```output +Name : testRoutingPolicyTable +Id : /subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/virtualHubs/testHub/hubRoutingPolicyTables/testRoutingPolicyTable +ProvisioningState : Succeeded +Labels : {testLabel} +RoutingPolicys : [ + { + "Name": "internet-traffic", + "DestinationType": "CIDR", + "Destinations": [ + "0.0.0.0/0" + ], + "NextHopType": "ResourceId", + "NextHop": "/subscriptions/testSub/resourceGroups/testRg/providers/Microsoft.Network/azureFirewalls/testFirewall" + } + ] +AssociatedConnections : [] +PropagatingConnections : [] +``` + +This command deletes the hub RoutingPolicy table of the virtual hub. + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -InputObject +The RoutingIntent resource to Set. + +```yaml +Type: PSRoutingIntent +Parameter Sets: ByRoutingIntentObject +Aliases: RoutingIntent, RoutingPolicyTable + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -Name +The resource name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName, ByVirtualHubObject +Aliases: ResourceName, RoutingIntentName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ParentObject +The parent virtual hub object of this resource. + +```yaml +Type: PSVirtualHub +Parameter Sets: ByVirtualHubObject +Aliases: ParentVirtualHub, VirtualHub + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByValue) +Accept wildcard characters: False +``` + +### -ParentResourceName +The parent resource name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName +Aliases: VirtualHubName, ParentVirtualHubName + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceGroupName +The resource group name. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentName +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -ResourceId +The resource id of the RoutingIntent resource to Set. + +```yaml +Type: String +Parameter Sets: ByRoutingIntentResourceId +Aliases: RoutingIntentId + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -RoutingPolicy +The list of RoutingPolicies to update in this routing intent reesource. + +```yaml +Type: PSRoutingPolicy[] +Parameter Sets: (All) +Aliases: ResourceName, RoutingIntentName + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### Microsoft.Azure.Commands.Network.Models.PSVirtualHub + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +### Microsoft.Azure.Commands.Network.Models.PSRoutingPolicy + +### System.String + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## NOTES + +## RELATED LINKS + +[Add-AzRoutingPolicy](./Add-AzRoutingPolicy.md) + +[Get-AzRoutingIntent](./Get-AzRoutingIntent.md) + +[Get-AzRoutingPolicy](./Get-AzRoutingPolicy.md) + +[New-AzRoutingPolicy](./New-AzRoutingPolicy.md) + +[Remove-AzRoutingIntent](./Remove-AzRoutingIntent.md) + +[Remove-AzRoutingPolicy](./Remove-AzRoutingPolicy.md) + +[Set-AzRoutingPolicy](./Set-AzRoutingPolicy.md) \ No newline at end of file diff --git a/src/Network/Network/help/Set-AzRoutingPolicy.md b/src/Network/Network/help/Set-AzRoutingPolicy.md new file mode 100644 index 000000000000..63257d32d10b --- /dev/null +++ b/src/Network/Network/help/Set-AzRoutingPolicy.md @@ -0,0 +1,202 @@ +--- +external help file: Microsoft.Azure.PowerShell.Cmdlets.Network.dll-Help.xml +Module Name: Az.Network +online version: https://docs.microsoft.com/powershell/module/az.network/set-azroutingpolicy +schema: 2.0.0 +--- + +# Set-AzRoutingPolicy + +## SYNOPSIS +Updates the destinations or nexthop for the specified Routing Policy of a Routing Intent object. + +## SYNTAX + +### (Default) +``` +Set-AzRoutingPolicy -RoutingIntent -Name [-Destination ] [-NextHop ] + [-Force] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] +``` + +## DESCRIPTION +The **Set-AzRoutingPolicy** cmdlet updates a RoutingPolicy of a RoutingIntent resource. This will only return an updated in-memory routing intent resource. Please use the [Set-AzRoutingIntent](./Set-AzRoutingIntent.md) cmdlet to update the actual resource and ensure that the policies take effect. + +## EXAMPLES + +### Example 1 +```powershell +$rgName = "testRg" +$firewallName = "testFirewall" +$firewall = Get-AzFirewall -Name $firewallName -ResourceGroupName $rgName +$routingIntent = Get-AzRoutingIntent -Name "routingIntent1" -HubName "hub1" -ResourceGroupName $rgName +Set-AzRoutingPolicy -Name "privateTrafficPolicy" -RoutingIntent $routingIntent -Destination @("10.0.0.0/8", "192.168.0.0/16") -NextHop $firewall.Id +``` + +## PARAMETERS + +### -AsJob +Run cmdlet in the background + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -DefaultProfile +The credentials, account, tenant, and subscription used for communication with Azure. + +```yaml +Type: Microsoft.Azure.Commands.Common.Authentication.Abstractions.Core.IAzureContextContainer +Parameter Sets: (All) +Aliases: AzContext, AzureRmContext, AzureCredential + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Force +Do not ask for confirmation if you want to overwrite a resource + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -Name +Name of the routing policy + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -NextHop +Id of the next hop resource. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Destination +The list of destinations. + +```yaml +Type: System.String[] +Parameter Sets: (All) +Aliases: ResourceName + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -RoutingIntent +The routing intent resource to which this rouing policy has to be added. + +```yaml +Type: Microsoft.Azure.Commands.Network.Models.PSRoutingIntent +Parameter Sets: (All) +Aliases: + +Required: True +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + +### -Confirm +Prompts you for confirmation before running the cmdlet. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: cf + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -WhatIf +Shows what would happen if the cmdlet runs. +The cmdlet is not run. + +```yaml +Type: System.Management.Automation.SwitchParameter +Parameter Sets: (All) +Aliases: wi + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### CommonParameters +This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216). + +## INPUTS + +### System.String + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## OUTPUTS + +### Microsoft.Azure.Commands.Network.Models.PSRoutingIntent + +## NOTES + +## RELATED LINKS + +[Get-AzRoutingIntent](./Get-AzRoutingIntent.md) + +[Get-AzRoutingPolicy](./Get-AzRoutingPolicy.md) + +[New-AzRoutingPolicy](./New-AzRoutingPolicy.md) + +[Remove-AzRoutingIntent](./Remove-AzRoutingIntent.md) + +[Remove-AzRoutingPolicy](./Remove-AzRoutingPolicy.md) + +[Set-AzRoutingIntent](./Set-AzRoutingIntent.md) + +[Set-AzRoutingPolicy](./Set-AzRoutingPolicy.md) \ No newline at end of file