Skip to content

Commit d928189

Browse files
Merge branch 'network-may-2022' of https://github.com/Azure/azure-powershell into network-may-2022
2 parents e1ba710 + 00a194c commit d928189

File tree

7 files changed

+165
-54
lines changed

7 files changed

+165
-54
lines changed

src/Network/Network/BYOIP/CustomIpPrefix/NewAzureCustomIpPrefixCommand.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ namespace Microsoft.Azure.Commands.Network
2121
using System.Collections;
2222
using System.Linq;
2323
using System.Management.Automation;
24+
using System.Text.RegularExpressions;
2425
using MNM = Microsoft.Azure.Management.Network.Models;
2526

2627
[Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "CustomIpPrefix", SupportsShouldProcess = true), OutputType(typeof(PSCustomIpPrefix))]
@@ -99,10 +100,13 @@ public class NewAzureCustomIpPrefixCommand : CustomIpPrefixBaseCmdlet
99100

100101
[Parameter(
101102
Mandatory = false,
102-
HelpMessage = "Parent CustomIpPrefix for /64 IPv6 CustomIpPrefix",
103+
HelpMessage = "Parent CustomIpPrefix for Child CustomIpPrefix",
103104
ValueFromPipelineByPropertyName = true)]
104105
public PSCustomIpPrefix CustomIpPrefixParent { get; set; }
105106

107+
[Parameter(Mandatory = false, HelpMessage = "Denotes that resource is being created as a Parent CustomIpPrefix")]
108+
public SwitchParameter IsParent { get; set; }
109+
106110
[Parameter(
107111
Mandatory = false,
108112
HelpMessage = "A list of availability zones denoting the IP allocated for the resource needs to come from.",
@@ -152,6 +156,22 @@ private PSCustomIpPrefix CreateCustomIpPrefix()
152156
ExpressRouteAdvertise = this.ExpressRouteAdvertise
153157
};
154158

159+
if (IsIPv4CIDR())
160+
{
161+
if (this.IsParent)
162+
{
163+
psModel.PrefixType = "Parent";
164+
}
165+
else if (this.CustomIpPrefixParent != null)
166+
{
167+
psModel.PrefixType = "Child";
168+
}
169+
else
170+
{
171+
psModel.PrefixType = "Singular";
172+
}
173+
}
174+
155175
var sdkModel = NetworkResourceManagerProfile.Mapper.Map<MNM.CustomIpPrefix>(psModel);
156176

157177
sdkModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);
@@ -167,5 +187,17 @@ private PSCustomIpPrefix CreateCustomIpPrefix()
167187

168188
return null;
169189
}
190+
191+
private bool IsIPv4CIDR()
192+
{
193+
if (this.Cidr != null)
194+
{
195+
return Regex.IsMatch(this.Cidr, @"^\d+\.\d+\.\d+\.\d+/\d+$");
196+
}
197+
else
198+
{
199+
return false;
200+
}
201+
}
170202
}
171203
}

src/Network/Network/ChangeLog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
--->
2020

2121
## Upcoming Release
22+
* Added a new endpoint swtich `AzureArcVM` in Networkwatcher ConnectionMonitor
23+
- `New-AzNetworkWatcherConnectionMonitor`
2224
* Updated commandlet to support bypassing the ExpressRoute gateway when accessing private-links.
2325
- `New-AzVirtualNetworkGatewayConnection`
2426
* Updated commandlet to support no-internet advertise CustomIpPrefix.
@@ -32,10 +34,12 @@
3234
* Updated commandlet to support bypassing NVA for spoke vNet traffic.
3335
- `NewAzureRmRoutingConfigurationCommand.cs`
3436
* Updated commandlet to support new parameters: asn, geo, expressrouteadvertise.
35-
- `Update-AzCustomIpPrefix
37+
- `Update-AzCustomIpPrefix`
3638
* Updated cmdlets to enable verification on client certificate revocation by using a new property VerifyClientRevocation in ApplicationGatewayClientAuthConfiguration
3739
- `New-AzApplicationGatewayClientAuthConfiguration`
3840
- `Set-AzApplicationGatewayClientAuthConfiguration`
41+
* Updated commandlet to support IPv4 Parent/Child CustomIpPrefix creation.
42+
- `New-AzCustomIpPrefix`
3943
* Added Uppercase Transform in New-AzApplicationGatewayFirewallCondition
4044
* Added DdosProtectionMode parameter in New-AzPublicIpAddress
4145
* Added ProbeThreshold parameter to Load Balancer Probe

src/Network/Network/Models/BYOIP/PSCustomIpPrefix.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public class PSCustomIpPrefix : PSTopLevelResource
4545

4646
public bool? ExpressRouteAdvertise { get; set; }
4747

48+
public string PrefixType { get; set; }
49+
4850
[JsonIgnore]
4951
public string PublicIpPrefixesText
5052
{

src/Network/Network/NetworkWatcher/ConnectionMonitor/ConnectionMonitorBaseCmdlet.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ private void ValidateEndpointType(PSNetworkWatcherConnectionMonitorEndpointObjec
802802
if (!string.Equals(endpoint.Type, "AzureVM", StringComparison.OrdinalIgnoreCase) && !string.Equals(endpoint.Type, "AzureVNet", StringComparison.OrdinalIgnoreCase)
803803
&& !string.Equals(endpoint.Type, "AzureSubnet", StringComparison.OrdinalIgnoreCase) && !string.Equals(endpoint.Type, "MMAWorkspaceMachine", StringComparison.OrdinalIgnoreCase)
804804
&& !string.Equals(endpoint.Type, "MMAWorkspaceNetwork", StringComparison.OrdinalIgnoreCase) && !string.Equals(endpoint.Type, "ExternalAddress", StringComparison.OrdinalIgnoreCase)
805-
&& !string.Equals(endpoint.Type, "AzureVMSS", StringComparison.OrdinalIgnoreCase))
805+
&& !string.Equals(endpoint.Type, "AzureVMSS", StringComparison.OrdinalIgnoreCase) && !string.Equals(endpoint.Type, "AzureArcVM", StringComparison.OrdinalIgnoreCase))
806806
{
807807
throw new PSArgumentException(Properties.Resources.InvalidEndpointType, endpoint.Name);
808808
}
@@ -827,7 +827,8 @@ private void ValidateEndpointResourceId(PSNetworkWatcherConnectionMonitorEndpoin
827827
if (string.IsNullOrEmpty(resourceType) || (!resourceType.Equals("virtualMachines", StringComparison.OrdinalIgnoreCase)
828828
&& !resourceType.Equals("workspaces", StringComparison.OrdinalIgnoreCase)
829829
&& !resourceType.Equals("virtualNetworks", StringComparison.OrdinalIgnoreCase)
830-
&& !resourceType.Equals("virtualMachineScaleSets", StringComparison.OrdinalIgnoreCase)))
830+
&& !resourceType.Equals("virtualMachineScaleSets", StringComparison.OrdinalIgnoreCase))
831+
&& !resourceType.Equals("machines", StringComparison.OrdinalIgnoreCase))
831832
{
832833
throw new PSArgumentException(Properties.Resources.InvalidEndpointResourceType);
833834
}
@@ -865,6 +866,12 @@ private void ValidateEndpointResourceId(PSNetworkWatcherConnectionMonitorEndpoin
865866
{
866867
throw new PSArgumentException(Properties.Resources.InvalidEndpointResourceIdForSpecifiedType, endpoint.Type);
867868
}
869+
} else if (string.Equals(endpoint.Type, "AzureArcVM", StringComparison.OrdinalIgnoreCase))
870+
{
871+
if (!resourceType.Equals("machines", StringComparison.OrdinalIgnoreCase))
872+
{
873+
throw new PSArgumentException(Properties.Resources.InvalidEndpointResourceIdForSpecifiedType, endpoint.Type);
874+
}
868875
}
869876
}
870877

src/Network/Network/NetworkWatcher/ConnectionMonitor/NewAzureNetworkWatcherConnectionMonitorEndPointObjectCommand.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ public class NewAzureNetworkWatcherConnectionMonitorEndpointObjectCommand : Conn
7272
ParameterSetName = "AzureVMSS")]
7373
public SwitchParameter AzureVMSS { get; set; }
7474

75+
[Parameter(
76+
Mandatory = true,
77+
HelpMessage = "Azure ArcVM endpoint switch.",
78+
ParameterSetName = "AzureArcVM")]
79+
public SwitchParameter AzureArcVM { get; set; }
80+
7581
[Parameter(
7682
Mandatory = true,
7783
HelpMessage = "Resource ID of the connection monitor endpoint.",
@@ -96,6 +102,10 @@ public class NewAzureNetworkWatcherConnectionMonitorEndpointObjectCommand : Conn
96102
Mandatory = true,
97103
HelpMessage = "Azure VMSS endpoint.",
98104
ParameterSetName = "AzureVMSS")]
105+
[Parameter(
106+
Mandatory = true,
107+
HelpMessage = "Azure ArcVM endpoint.",
108+
ParameterSetName = "AzureArcVM")]
99109
[ValidateNotNullOrEmpty]
100110
public string ResourceId { get; set; }
101111

@@ -249,6 +259,10 @@ private string GetEndpointType()
249259
{
250260
return "AzureVMSS";
251261
}
262+
else if (AzureArcVM.IsPresent)
263+
{
264+
return "AzureArcVM";
265+
}
252266

253267
return string.Empty;
254268
}

0 commit comments

Comments
 (0)