Skip to content

Commit 8e11016

Browse files
author
Maddie Clayton
authored
Merge pull request #7261 from ritwikbasu/nalin-september-release
Adding support for security provider integration in cortex cmdlets.
2 parents 80b9d22 + 530e6e9 commit 8e11016

32 files changed

+9691
-7131
lines changed

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/CortexTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public CortexTests(ITestOutputHelper output)
3030
XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
3131
}
3232

33-
[Fact( Skip = "TODO, #7260: needs to be re-recorded")]
33+
[Fact]
3434
[Trait(Category.Owner, Category.brooklynft)]
3535
public void TestCortexCRUD()
3636
{

src/ResourceManager/Network/Commands.Network.Test/ScenarioTests/CortexTests.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ function Test-CortexCRUD
4646
Assert-AreEqual $false $virtualWan.AllowVnetToVnetTraffic
4747
Assert-AreEqual $false $virtualWan.AllowBranchToBranchTraffic
4848

49+
# Get Supported SecurityProvider
50+
$supportedSecurityProvider = Get-AzureRmVirtualWanSupportedSecurityProvider -ResourceGroupName $rgName -VirtualWanName $virtualWanName
51+
Assert-NotNull $supportedSecurityProvider
52+
4953
# Create the Virtual Hub
5054
$createdVirtualHub = New-AzureRmVirtualHub -ResourceGroupName $rgName -Name $virtualHubName -Location $rglocation -AddressPrefix "192.168.1.0/24" -VirtualWan $virtualWan
5155
$virtualHub = Get-AzureRmVirtualHub -ResourceGroupName $rgName -Name $virtualHubName
@@ -95,6 +99,11 @@ function Test-CortexCRUD
9599
$hubVnetConnection = Get-AzureRmVirtualHubVnetConnection -ResourceGroupName $rgName -VirtualHubName $virtualHubName -Name $hubVnetConnectionName
96100
Assert-AreEqual $hubVnetConnectionName $hubVnetConnection.Name
97101

102+
# Update a HubVirtualNetworkConnection
103+
Update-AzureRmVirtualHubVnetConnection -ResourceGroupName $rgName -VirtualHubName $virtualHubName -Name $hubVnetConnectionName -EnableInternetSecurity $true
104+
$hubVnetConnection = Get-AzureRmVirtualHubVnetConnection -ResourceGroupName $rgName -VirtualHubName $virtualHubName -Name $hubVnetConnectionName
105+
Assert-AreEqual $hubVnetConnection.EnableInternetSecurity $true
106+
98107
# Download config
99108
$storetype = 'Standard_GRS'
100109
$containerName = 'cont' + $rgName

src/ResourceManager/Network/Commands.Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.CortexTests/TestCortexCRUD.json

Lines changed: 6320 additions & 4714 deletions
Large diffs are not rendered by default.

src/ResourceManager/Network/Commands.Network/Az.Network.psd1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,10 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
387387
'Remove-AzVpnConnection',
388388
'New-AzVirtualHubVnetConnection',
389389
'Get-AzVirtualHubVnetConnection',
390+
'Update-AzVirtualHubVnetConnection',
390391
'Remove-AzVirtualHubVnetConnection',
391392
'Get-AzVirtualWanVpnConfiguration',
393+
'Get-AzVirtualWanSupportedSecurityProvider',
392394
'Get-AzFirewall',
393395
'Set-AzFirewall',
394396
'New-AzFirewall',

src/ResourceManager/Network/Commands.Network/AzureRM.Network.psd1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,11 @@ CmdletsToExport = 'Add-AzureRmApplicationGatewayAuthenticationCertificate',
384384
'Update-AzureRmVpnConnection',
385385
'Remove-AzureRmVpnConnection',
386386
'New-AzureRmVirtualHubVnetConnection',
387+
'Update-AzureRmVirtualHubVnetConnection',
387388
'Get-AzureRmVirtualHubVnetConnection',
388389
'Remove-AzureRmVirtualHubVnetConnection',
389390
'Get-AzureRmVirtualWanVpnConfiguration',
391+
'Get-AzureRmVirtualWanSupportedSecurityProvider',
390392
'Get-AzureRmFirewall',
391393
'Set-AzureRmFirewall',
392394
'New-AzureRmFirewall',

src/ResourceManager/Network/Commands.Network/ChangeLog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919
--->
2020

2121
## Current Release
22+
* Added cmdlets to integrate security provider in cortex
23+
- Cmdlets updated with optonal parameters
24+
- New-AzureRmVirtualWan : added parameters SecurityProviderName, Office365LocalBreakoutCategory
25+
- Update-AzureRmVirtualWan : added parameters SecurityProviderName, Office365LocalBreakoutCategory
26+
- New-AzureRmVpnSite : added parameter IsSecuritySite
27+
- New-AzureRmVpnConnection : added parameter EnableInternetSecurity
28+
- Update-AzureRmVpnConnection : added parameter EnableInternetSecurity
29+
- New-AzureRmVirtualHubVnetConnection : added parameter EnableInternetSecurity
30+
- New Cmdlets added:
31+
- Get-AzureRmVirtualWanSupportedSecurityProvider
32+
- Update-AzureRmVirtualHubVnetConnection
2233

2334
## Version 6.8.0
2435
* Replaced LoadBalancer cmdlets with generated code

src/ResourceManager/Network/Commands.Network/Commands.Network.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@
198198
<Compile Include="AzureFirewall\RemoveAzureFirewallCommand.cs" />
199199
<Compile Include="AzureFirewall\SetAzureFirewallCommand.cs" />
200200
<Compile Include="InterfaceEndpoint\AzureInterfaceEndpointBaseCmdlet.cs" />
201+
<Compile Include="Cortex\HubVnetConnection\UpdateAzureRmHubVirtualNetworkConnectionCommand.cs" />
202+
<Compile Include="Cortex\VirtualWan\GetAzureRmVirtualWanSupportedSecurityProviderCommand.cs" />
201203
<Compile Include="Generated\ApplicationSecurityGroup\GetAzureRMApplicationSecurityGroupCommand.cs" />
202204
<Compile Include="Generated\ApplicationSecurityGroup\NewAzureRMApplicationSecurityGroupCommand.cs" />
203205
<Compile Include="Generated\ApplicationSecurityGroup\RemoveAzureRMApplicationSecurityGroupCommand.cs" />
@@ -362,6 +364,7 @@
362364
<Compile Include="Generated\Models\PSTroubleshootingDetails.cs" />
363365
<Compile Include="Generated\Models\PSTroubleshootingRecommendedActions.cs" />
364366
<Compile Include="InterfaceEndpoint\GetAzureInterfaceEndpointCommand.cs" />
367+
<Compile Include="Models\Cortex\PSVirtualWanSecurityProvider.cs" />
365368
<Compile Include="Models\PSTrafficAnalyticsConfigurationProperties.cs" />
366369
<Compile Include="Models\PSTrafficAnalyticsProperties.cs" />
367370
<Compile Include="Generated\Models\PSTunnelConnectionHealth.cs" />

src/ResourceManager/Network/Commands.Network/Cortex/HubVnetConnection/NewAzureRmHubVirtualNetworkConnectionCommand.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ public class NewHubVirtualNetworkConnectionCommand : HubVnetConnectionBaseCmdlet
123123
[ResourceIdCompleter("Microsoft.Network/virtualNetworks")]
124124
public string RemoteVirtualNetworkId { get; set; }
125125

126+
[Parameter(
127+
Mandatory = false,
128+
HelpMessage = "Enable internet security for this connection")]
129+
public SwitchParameter EnableInternetSecurity { get; set; }
130+
126131
[Parameter(
127132
Mandatory = false,
128133
HelpMessage = "Run cmdlet in the background")]
@@ -158,6 +163,7 @@ public override void Execute()
158163

159164
PSHubVirtualNetworkConnection hubVnetConnection = new PSHubVirtualNetworkConnection();
160165
hubVnetConnection.Name = this.Name;
166+
hubVnetConnection.EnableInternetSecurity = this.EnableInternetSecurity.IsPresent;
161167

162168
//// Resolve the remote virtual network
163169
//// Let's not try to resolve this since this can be in other RG/Sub/Location
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Network
16+
{
17+
using AutoMapper;
18+
using System;
19+
using System.Collections;
20+
using System.Collections.Generic;
21+
using System.Management.Automation;
22+
using System.Security;
23+
using Microsoft.Azure.Commands.Network.Models;
24+
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
25+
using Microsoft.Azure.Management.Network;
26+
using Microsoft.WindowsAzure.Commands.Common;
27+
using MNM = Microsoft.Azure.Management.Network.Models;
28+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
29+
using System.Linq;
30+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
31+
32+
[Cmdlet("Update",
33+
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualHubVnetConnection",
34+
DefaultParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionName,
35+
SupportsShouldProcess = true),
36+
OutputType(typeof(PSHubVirtualNetworkConnection))]
37+
public class UpdateAzureRmHubVirtualNetworkConnectionCommand : HubVnetConnectionBaseCmdlet
38+
{
39+
[Parameter(
40+
Mandatory = true,
41+
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionName,
42+
HelpMessage = "The resource group name.")]
43+
[ResourceGroupCompleter]
44+
[ValidateNotNullOrEmpty]
45+
public virtual string ResourceGroupName { get; set; }
46+
47+
[Alias("VirtualHubName", "ParentVirtualHubName")]
48+
[Parameter(
49+
Mandatory = true,
50+
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionName,
51+
HelpMessage = "The parent resource name.")]
52+
[ResourceGroupCompleter]
53+
public string ParentResourceName { get; set; }
54+
55+
[Alias("ResourceName", "HubVirtualNetworkConnectionName")]
56+
[Parameter(
57+
Mandatory = true,
58+
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionName,
59+
HelpMessage = "The resource name.")]
60+
[ValidateNotNullOrEmpty]
61+
public virtual string Name { get; set; }
62+
63+
[Alias("HubVirtualNetworkConnection")]
64+
[Parameter(
65+
Mandatory = true,
66+
ValueFromPipeline = true,
67+
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionObject,
68+
HelpMessage = "The hubvirtualnetworkconnection resource to modify.")]
69+
public PSHubVirtualNetworkConnection InputObject { get; set; }
70+
71+
[Alias("HubVirtualNetworkConnectionId")]
72+
[Parameter(
73+
Mandatory = true,
74+
ValueFromPipelineByPropertyName = true,
75+
ParameterSetName = CortexParameterSetNames.ByHubVirtualNetworkConnectionResourceId,
76+
HelpMessage = "The resource id of the hubvirtualnetworkconnection resource to modify.")]
77+
public string ResourceId { get; set; }
78+
79+
[Parameter(
80+
Mandatory = false,
81+
HelpMessage = "Enable internet security for this connection.")]
82+
public bool? EnableInternetSecurity { get; set; }
83+
84+
[Parameter(
85+
Mandatory = false,
86+
HelpMessage = "Run cmdlet in the background")]
87+
public SwitchParameter AsJob { get; set; }
88+
89+
public override void Execute()
90+
{
91+
base.Execute();
92+
93+
//// Resolve the VirtualHub
94+
if (ParameterSetName.Equals(CortexParameterSetNames.ByHubVirtualNetworkConnectionObject, StringComparison.OrdinalIgnoreCase))
95+
{
96+
this.ResourceId = this.InputObject.Id;
97+
98+
if (string.IsNullOrWhiteSpace(this.ResourceId))
99+
{
100+
throw new PSArgumentException(Properties.Resources.HubVnetConnectionNotFound);
101+
}
102+
103+
var parsedResourceId = new ResourceIdentifier(this.ResourceId);
104+
this.ResourceGroupName = parsedResourceId.ResourceGroupName;
105+
this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
106+
this.Name = parsedResourceId.ResourceName;
107+
}
108+
else if (ParameterSetName.Equals(CortexParameterSetNames.ByHubVirtualNetworkConnectionResourceId, StringComparison.OrdinalIgnoreCase))
109+
{
110+
var parsedResourceId = new ResourceIdentifier(this.ResourceId);
111+
this.ResourceGroupName = parsedResourceId.ResourceGroupName;
112+
this.ParentResourceName = parsedResourceId.ParentResource.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Last();
113+
this.Name = parsedResourceId.ResourceName;
114+
}
115+
116+
//// Get the virtual hub - this will throw not found if the resource is invalid
117+
PSVirtualHub parentVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName);
118+
119+
var connectionToModify = parentVirtualHub.VirtualNetworkConnections.FirstOrDefault(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase));
120+
if (connectionToModify == null)
121+
{
122+
throw new PSArgumentException(Properties.Resources.HubVnetConnectionNotFound);
123+
}
124+
125+
if (this.EnableInternetSecurity.HasValue)
126+
{
127+
connectionToModify.EnableInternetSecurity = this.EnableInternetSecurity.Value;
128+
}
129+
130+
ConfirmAction(
131+
Properties.Resources.SettingResourceMessage,
132+
this.Name,
133+
() =>
134+
{
135+
this.CreateOrUpdateVirtualHub(this.ResourceGroupName, this.ParentResourceName, parentVirtualHub, parentVirtualHub.Tag);
136+
var updatedVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName);
137+
138+
WriteObject(updatedVirtualHub.VirtualNetworkConnections.FirstOrDefault(hubConnection => hubConnection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)));
139+
});
140+
}
141+
}
142+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
namespace Microsoft.Azure.Commands.Network
16+
{
17+
using System;
18+
using System.Management.Automation;
19+
using Microsoft.Azure.Commands.Network.Models;
20+
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
21+
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
22+
using Microsoft.Azure.Management.Network;
23+
24+
[Cmdlet(
25+
VerbsCommon.Get,
26+
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualWanSupportedSecurityProvider",
27+
DefaultParameterSetName = CortexParameterSetNames.ByVirtualWanName),
28+
OutputType(typeof(PSVirtualWanSecurityProvider))]
29+
public class GetAzureRmVirtualWanSupportedSecurityProviderCommand : VirtualWanBaseCmdlet
30+
{
31+
[Parameter(
32+
ParameterSetName = CortexParameterSetNames.ByVirtualWanName,
33+
Mandatory = true,
34+
HelpMessage = "The resource group name.")]
35+
[ResourceGroupCompleter]
36+
[ValidateNotNullOrEmpty]
37+
public string ResourceGroupName { get; set; }
38+
39+
[Alias("ResourceName", "VirtualWanName")]
40+
[Parameter(
41+
ParameterSetName = CortexParameterSetNames.ByVirtualWanName,
42+
Mandatory = true,
43+
HelpMessage = "The resource name.")]
44+
[ValidateNotNullOrEmpty]
45+
public string Name { get; set; }
46+
47+
[Alias("VirtualWan")]
48+
[Parameter(
49+
ParameterSetName = CortexParameterSetNames.ByVirtualWanObject,
50+
Mandatory = true,
51+
ValueFromPipeline = true,
52+
HelpMessage = "The virtual wan object to be modified")]
53+
[ValidateNotNullOrEmpty]
54+
public PSVirtualWan InputObject { get; set; }
55+
56+
[Alias("VirtualWanId")]
57+
[Parameter(
58+
ParameterSetName = CortexParameterSetNames.ByVirtualWanResourceId,
59+
Mandatory = true,
60+
ValueFromPipelineByPropertyName = true,
61+
HelpMessage = "The Azure resource ID for the virtual wan.")]
62+
public string ResourceId { get; set; }
63+
64+
public override void Execute()
65+
{
66+
base.Execute();
67+
68+
//// Resolve the virtual wan
69+
if (ParameterSetName.Contains(CortexParameterSetNames.ByVirtualWanObject))
70+
{
71+
this.ResourceGroupName = this.InputObject.ResourceGroupName;
72+
this.Name = this.InputObject.Name;
73+
}
74+
else if (ParameterSetName.Equals(CortexParameterSetNames.ByVirtualWanResourceId))
75+
{
76+
var parsedResourceId = new ResourceIdentifier(this.ResourceId);
77+
this.ResourceGroupName = parsedResourceId.ResourceGroupName;
78+
this.Name = parsedResourceId.ResourceName;
79+
}
80+
81+
if (string.IsNullOrWhiteSpace(this.ResourceGroupName) || string.IsNullOrWhiteSpace(this.Name))
82+
{
83+
throw new PSArgumentException(Properties.Resources.VirtualWanRequiredForVpnSiteConfiguration);
84+
}
85+
86+
var supportedSecurityProviders = NetworkClient.NetworkManagementClient.SupportedSecurityProviders(this.ResourceGroupName, this.Name);
87+
WriteObject(supportedSecurityProviders.SupportedProviders);
88+
}
89+
}
90+
}

src/ResourceManager/Network/Commands.Network/Cortex/VirtualWan/NewAzureRmVirtualWanCommand.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@ public class NewAzureRmVirtualWanCommand : VirtualWanBaseCmdlet
5454
[ValidateNotNullOrEmpty]
5555
public string Location { get; set; }
5656

57+
[Parameter(
58+
Mandatory = false,
59+
HelpMessage = "The name of the selected security provider.")]
60+
public string SecurityProviderName { get; set; }
61+
62+
[Parameter(
63+
Mandatory = false,
64+
HelpMessage = "Local breakout category for office 365 traffic.")]
65+
[ValidateSet(MNM.OfficeTrafficCategory.All, MNM.OfficeTrafficCategory.None, MNM.OfficeTrafficCategory.Optimize, MNM.OfficeTrafficCategory.OptimizeAndAllow)]
66+
public string Office365LocalBreakoutCategory { get; set; }
67+
5768
[Parameter(
5869
Mandatory = false,
5970
HelpMessage = "Allow vnet to vnet traffic for VirtualWan.")]
@@ -99,6 +110,8 @@ private PSVirtualWan CreateVirtualWan()
99110
virtualWan.Name = this.Name;
100111
virtualWan.ResourceGroupName = this.ResourceGroupName;
101112
virtualWan.Location = this.Location;
113+
virtualWan.SecurityProviderName = this.SecurityProviderName;
114+
virtualWan.Office365LocalBreakoutCategory = this.Office365LocalBreakoutCategory;
102115
virtualWan.AllowBranchToBranchTraffic = this.AllowBranchToBranchTraffic.IsPresent;
103116
virtualWan.AllowVnetToVnetTraffic = this.AllowVnetToVnetTraffic.IsPresent;
104117

0 commit comments

Comments
 (0)