Skip to content

Commit

Permalink
Add features to Network (Azure#19696)
Browse files Browse the repository at this point in the history
* draft pr

* second commit

* added mappings

* minor fixes

* change psextendedloc

* add extendedlocation in ps1xml

* changelog

* Update ChangeLog.md

* regenerate help docs

* regenerate help doc

* new help doc manual

Co-authored-by: Yabo Hu <[email protected]>
  • Loading branch information
tguxia and VeryEarly authored Oct 25, 2022
1 parent 74cb235 commit 76c8995
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/Network/Network/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
--->

## Upcoming Release
* Added possible value `LocalGateway` for parameter `GatewayType`
- `New-AzVirtualNetworkGateway`
* Exposed `ExtendedLocation` and `VNetExtendedLocationResourceId` for `VirtualNetworkGateway`
- `Get-AzVirtualNetworkGateway`
* Added new cmdlet to get firewall learned ip prefixes
* `Get-AzFirewallLearnedIpPrefix`
* Fixed a bug that does not update firewall policy application, network and nat rules' descriptions even though description is provided via description parameter
Expand Down
2 changes: 2 additions & 0 deletions src/Network/Network/Common/NetworkResourceManagerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,7 @@ private static void Initialize()
cfg.CreateMap<CNM.PSVpnClientConnectionHealthDetail, MNM.VpnClientConnectionHealthDetail>();
cfg.CreateMap<CNM.PSIpConfigurationBgpPeeringAddress, MNM.IPConfigurationBgpPeeringAddress>();
cfg.CreateMap<CNM.PSVirtualNetworkGatewayNatRule, MNM.VirtualNetworkGatewayNatRule>();
cfg.CreateMap<CNM.PSExtendedLocation, MNM.ExtendedLocation>();
cfg.CreateMap<CNM.PSVirtualNetworkGatewayPolicyGroup, MNM.VirtualNetworkGatewayPolicyGroup>();
cfg.CreateMap<CNM.PSVirtualNetworkGatewayPolicyGroupMember, MNM.VirtualNetworkGatewayPolicyGroupMember>();
cfg.CreateMap<CNM.PSClientConnectionConfiguration, MNM.VngClientConnectionConfiguration>();
Expand All @@ -957,6 +958,7 @@ private static void Initialize()
cfg.CreateMap<MNM.VpnClientConnectionHealthDetail, CNM.PSVpnClientConnectionHealthDetail>();
cfg.CreateMap<MNM.IPConfigurationBgpPeeringAddress, CNM.PSIpConfigurationBgpPeeringAddress>();
cfg.CreateMap<MNM.VirtualNetworkGatewayNatRule, CNM.PSVirtualNetworkGatewayNatRule>();
cfg.CreateMap<MNM.ExtendedLocation, CNM.PSExtendedLocation>();
cfg.CreateMap<MNM.VirtualNetworkGatewayPolicyGroup, CNM.PSVirtualNetworkGatewayPolicyGroup>();
cfg.CreateMap<MNM.VirtualNetworkGatewayPolicyGroupMember, CNM.PSVirtualNetworkGatewayPolicyGroupMember>();
cfg.CreateMap<MNM.VngClientConnectionConfiguration, CNM.PSClientConnectionConfiguration>();
Expand Down
6 changes: 3 additions & 3 deletions src/Network/Network/Models/PSExtendedLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
namespace Microsoft.Azure.Commands.Network.Models
{
using Microsoft.Azure.Management.Network.Models;
using Microsoft.WindowsAzure.Commands.Common.Attributes;

public class PSExtendedLocation
public class PSExtendedLocation : PSChildResource
{
public PSExtendedLocation()
{ }
Expand All @@ -30,8 +31,7 @@ public PSExtendedLocation(string EdgeZone)
this.Type = extendedLocation.Type;
}

public string Name { get; set; }

[Ps1Xml(Label = "Type", Target = ViewControl.Table)]
public string Type { get; set; }
}
}
19 changes: 19 additions & 0 deletions src/Network/Network/Models/PSVirtualNetworkGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Microsoft.Azure.Commands.Network.Models
using Newtonsoft.Json;
using System.Collections.Generic;
using WindowsAzure.Commands.Common.Attributes;
using Microsoft.Azure.Management.Network.Models;

public class PSVirtualNetworkGateway : PSTopLevelResource
{
Expand Down Expand Up @@ -57,6 +58,12 @@ public class PSVirtualNetworkGateway : PSTopLevelResource

public string VpnGatewayGeneration { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public PSExtendedLocation ExtendedLocation { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
public string VNetExtendedLocationResourceId { get; set; }

public List<PSVirtualNetworkGatewayNatRule> NatRules { get; set; }

[Ps1Xml(Target = ViewControl.Table)]
Expand All @@ -68,6 +75,18 @@ public string IpConfigurationsText
get { return JsonConvert.SerializeObject(IpConfigurations, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string ExtendedLocationText
{
get { return JsonConvert.SerializeObject(ExtendedLocation, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string VNetExtendedLocationResourceIdText
{
get { return JsonConvert.SerializeObject(VNetExtendedLocationResourceId, Formatting.Indented, new JsonSerializerSettings() { NullValueHandling = NullValueHandling.Ignore }); }
}

[JsonIgnore]
public string GatewayDefaultSiteText
{
Expand Down
4 changes: 4 additions & 0 deletions src/Network/Network/Network.format.ps1xml
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,10 @@
<Label>NatRules</Label>
<PropertyName>NatRulesText</PropertyName>
</ListItem>
<ListItem>
<Label>ExtendedLocation</Label>
<PropertyName>ExtendedLocationText</PropertyName>
</ListItem>
<ListItem>
<Label>EnableBgpRouteTranslationForNat</Label>
<PropertyName>EnableBgpRouteTranslationForNat</PropertyName>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,30 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd
[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The type of this virtual network gateway: Vpn, ExoressRoute")]
HelpMessage = "The type of this virtual network gateway: Vpn, ExoressRoute, LocalGateway")]
[ValidateSet(
MNM.VirtualNetworkGatewayType.Vpn,
MNM.VirtualNetworkGatewayType.ExpressRoute,
MNM.VirtualNetworkGatewayType.LocalGateway,
IgnoreCase = true)]
public string GatewayType { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The extended location of this virtual network gateway")]
[ValidateSet(
"MicrosoftRRDCLab3",
IgnoreCase = true)]
public string ExtendedLocation { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "VNetExtendedLocationResourceId for Virtual network gateway.")]
[ValidateNotNullOrEmpty]
public string VNetExtendedLocationResourceId { get; set; }

[Parameter(
Mandatory = false,
ValueFromPipelineByPropertyName = true,
Expand Down Expand Up @@ -376,6 +393,11 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway()

}
vnetGateway.GatewayType = this.GatewayType;
if(vnetGateway.GatewayType == "LocalGateway")
{
vnetGateway.ExtendedLocation = new PSExtendedLocation(this.ExtendedLocation);
vnetGateway.VNetExtendedLocationResourceId = this.VNetExtendedLocationResourceId;
}
vnetGateway.VpnType = this.VpnType;
vnetGateway.EnableBgp = this.EnableBgp;
vnetGateway.DisableIPsecProtection = this.DisableIPsecProtection;
Expand Down
34 changes: 33 additions & 1 deletion src/Network/Network/help/New-AzVirtualNetworkGateway.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Creates a Virtual Network Gateway
```
New-AzVirtualNetworkGateway -Name <String> -ResourceGroupName <String> -Location <String>
[-IpConfigurations <PSVirtualNetworkGatewayIpConfiguration[]>] [-GatewayType <String>] [-VpnType <String>]
[-ExtendedLocation <String>] [-VNetExtendedLocationResourceId <String>] [-VpnType <String>]
[-EnableBgp <Boolean>] [-DisableIPsecProtection <Boolean>] [-EnableActiveActiveFeature]
[-EnablePrivateIpAddress] [-GatewaySku <String>] [-GatewayDefaultSite <PSLocalNetworkGateway>]
[-VpnClientAddressPool <String[]>] [-VpnClientProtocol <String[]>] [-VpnAuthenticationType <String[]>]
Expand Down Expand Up @@ -380,6 +381,22 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ExtendedLocation
The extended location of this virtual network gateway
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:
Accepted values: MicrosoftRRDCLab3

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -Force
Do not ask for confirmation if you want to overwrite a resource
Expand Down Expand Up @@ -433,7 +450,7 @@ The type of this virtual network gateway: Vpn, ExpressRoute
Type: System.String
Parameter Sets: (All)
Aliases:
Accepted values: Vpn, ExpressRoute
Accepted values: Vpn, ExpressRoute, LocalGateway

Required: False
Position: Named
Expand Down Expand Up @@ -622,6 +639,21 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -VNetExtendedLocationResourceId
VNetExtendedLocationResourceId for Virtual network gateway.
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```
### -VpnAuthenticationType
The list of P2S VPN client authentication types.
Expand Down

0 comments on commit 76c8995

Please sign in to comment.