Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
30533a9
Vwan: Use hubvnet rest API for Hubvnet operations
May 21, 2020
ec29a9e
Vwan: Use hubvnet CRUD api in virtual hub too
May 25, 2020
2b76cb9
PR: LoadBalancerBackendAddressPool powershell Cmdlets (#11734)
aegal May 30, 2020
e5fcd5c
Adding new optional parameter to specify dns servers for Virtual Wan …
Nilambari Jun 1, 2020
b242a55
updating help files examples (#12068)
aegal Jun 5, 2020
10c3779
multipip changes
saisujithreddym Jun 7, 2020
b7c50ca
Do not pass new fields with default values unless configured explicit…
tejasshah7 Jun 8, 2020
8facadd
multi pip changes
saisujithreddym Jun 8, 2020
e906963
ps tests
saisujithreddym Jun 8, 2020
692ca3e
generating help files
saisujithreddym Jun 9, 2020
22d59d3
help files changes
saisujithreddym Jun 9, 2020
f8d8dbe
help file
saisujithreddym Jun 9, 2020
9b139a7
regenerating help files
saisujithreddym Jun 9, 2020
d7965e9
updated markdown file
saisujithreddym Jun 9, 2020
f580e30
renaming the cmdlets
saisujithreddym Jun 9, 2020
a8431d9
name change
saisujithreddym Jun 9, 2020
ab3fcbc
Vwan: Hubvnet connection related fixes
Jun 9, 2020
fb28c7a
Merge branch 'network-may' into shdharma/deprecate-hubvnet-conn-from-hub
shyamshd Jun 9, 2020
807e8db
tests
saisujithreddym Jun 9, 2020
e370187
renaming a help file
saisujithreddym Jun 9, 2020
aea252b
updating the recordings
saisujithreddym Jun 10, 2020
a94e0cd
test
saisujithreddym Jun 10, 2020
6a9de29
Used signed Network SDK with API version 2020-05-01 (#12100)
anton-evseev Jun 10, 2020
4a1af5d
rebase and resolved the conflicts
saisujithreddym Jun 10, 2020
e3abbbd
clean up
saisujithreddym Jun 10, 2020
b4922e5
updatid recordings
saisujithreddym Jun 10, 2020
f1b8bc2
clean up
saisujithreddym Jun 10, 2020
ab3e007
clean up
saisujithreddym Jun 10, 2020
b31b6a7
Vpn gateway commandlet update (#12108)
Khushboo-Baheti Jun 10, 2020
32bb5fb
addressing comments
saisujithreddym Jun 10, 2020
4a6738e
added exceptions
saisujithreddym Jun 10, 2020
1653001
correcting the exceptions
saisujithreddym Jun 10, 2020
f21cd07
Change RuleGroup, RuleCollectionGroup, and RuleType and add support f…
tejasshah7 Jun 10, 2020
0ffe125
update to vnet reference id only
aegal Jun 10, 2020
5248182
Use Network SDK from NuGet (#12114)
anton-evseev Jun 11, 2020
28eddfd
Merge remote-tracking branch 'Azure/network-may' into shdharma/deprec…
Jun 11, 2020
6ada202
Vwan hubvnet connection changes: Update help files
Jun 11, 2020
18d1c76
Firewall Policy ThreatIntelWhitelist (#12078)
saisujithreddym Jun 11, 2020
388a4c3
resolving conflicts
saisujithreddym Jun 11, 2020
c1e4191
Merge pull request #12093 from sujith-powershell/network-may-multipip
saisujithreddym Jun 11, 2020
63e4380
PR: LoadBalancerBackendAddressPool powershell Cmdlets (#11734)
aegal May 30, 2020
6a2f7ef
Adding new optional parameter to specify dns servers for Virtual Wan …
Jun 11, 2020
0fb7a04
updating help files examples (#12068)
aegal Jun 5, 2020
385574a
Do not pass new fields with default values unless configured explicit…
tejasshah7 Jun 8, 2020
c0d1333
Used signed Network SDK with API version 2020-05-01 (#12100)
anton-evseev Jun 10, 2020
063dec1
Vpn gateway commandlet update (#12108)
Khushboo-Baheti Jun 10, 2020
b697b93
Change RuleGroup, RuleCollectionGroup, and RuleType and add support f…
tejasshah7 Jun 10, 2020
0706e06
Use Network SDK from NuGet (#12114)
anton-evseev Jun 11, 2020
e89a8c2
Vwan hubvnet connection changes: Update help files
Jun 11, 2020
148453b
Merge branch 'shdharma/deprecate-hubvnet-conn-from-hub' of https://gi…
Jun 11, 2020
e211b12
Merge branch 'network-may' into updateVnetReference
aegal Jun 11, 2020
56297c4
updating due to validation error on CICD pipeline
aegal Jun 11, 2020
b44bafe
refreshing test files, updating to remove id from variable to fix cas…
aegal Jun 12, 2020
f7b324f
DNS Proxy in Firewall Policy (#12120)
ishaniGupta27 Jun 12, 2020
82068e2
Add support for IPGroups in Firewall Policy Rules (#12118)
tejasshah7 Jun 12, 2020
f6b8af1
Merge pull request #12117 from Azure/updateVnetReference
aegal Jun 12, 2020
27661df
Application Gateway Private Link Cmdlets (#12133)
jaishals Jun 13, 2020
69a8d24
Add new cmdlet Reset-AzHubRouter (#12094)
nagula-ritvika Jun 15, 2020
3575979
Vwan hubvnet connection changes: Update test
Jun 12, 2020
6c65204
Merge branch 'network-may' into shdharma/deprecate-hubvnet-conn-from-hub
Jun 15, 2020
6548e64
Update newly added test.
Jun 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace Microsoft.Azure.Commands.Network
using System.Net;
using MNM = Microsoft.Azure.Management.Network.Models;

public class HubVnetConnectionBaseCmdlet : VirtualHubBaseCmdlet
public class HubVnetConnectionBaseCmdlet : NetworkBaseCmdlet
{
public IHubVirtualNetworkConnectionsOperations HubVirtualNetworkConnectionsClient
{
Expand All @@ -39,6 +39,26 @@ public PSHubVirtualNetworkConnection ToPsHubVirtualNetworkConnection(Management.
return psVirtualHubVirtualNetworkConnection;
}

public PSHubVirtualNetworkConnection CreateOrUpdateHubVirtualNetworkConnection(string resourceGroupName, string virtualHubName, string connectionName, MNM.HubVirtualNetworkConnection hubVirtualNetworkConnectionParameters, Dictionary<string, List<string>> customHeaders = null)
{
MNM.HubVirtualNetworkConnection hubVnetConnCreated;

if (customHeaders == null)
{
hubVnetConnCreated = this.HubVirtualNetworkConnectionsClient.CreateOrUpdate(resourceGroupName, virtualHubName, connectionName, hubVirtualNetworkConnectionParameters);
}
else
{
// Execute the create call and pass the custom headers.
using (var _result = this.HubVirtualNetworkConnectionsClient.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, connectionName, virtualHubName, hubVirtualNetworkConnectionParameters, customHeaders).GetAwaiter().GetResult())
{
hubVnetConnCreated = _result.Body;
}
}

return this.ToPsHubVirtualNetworkConnection(hubVnetConnCreated);
}

public PSHubVirtualNetworkConnection GetHubVirtualNetworkConnection(string resourceGroupName, string virtualHubName, string name)
{
var virtualHubConnection = this.HubVirtualNetworkConnectionsClient.Get(resourceGroupName, virtualHubName, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Microsoft.Azure.Commands.Network
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using System.Linq;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;

[Cmdlet(VerbsCommon.New,
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualHubVnetConnection",
Expand Down Expand Up @@ -124,11 +125,17 @@ public class NewHubVirtualNetworkConnectionCommand : HubVnetConnectionBaseCmdlet
[ResourceIdCompleter("Microsoft.Network/virtualNetworks")]
public string RemoteVirtualNetworkId { get; set; }

[CmdletParameterBreakingChange("EnableInternetSecurity", OldParamaterType = typeof(SwitchParameter), NewParameterTypeName = "EnableInternetSecurityFlag")]
[Parameter(
Mandatory = false,
HelpMessage = "Enable internet security for this connection")]
public SwitchParameter EnableInternetSecurity { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Enable internet security for this connection")]
public bool? EnableInternetSecurityFlag { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Run cmdlet in the background")]
Expand Down Expand Up @@ -156,33 +163,25 @@ public override void Execute()
throw new PSArgumentException(string.Format(Properties.Resources.ChildResourceAlreadyPresentInResourceGroup, this.Name, this.ResourceGroupName, this.ParentResourceName));
}

//// Get the virtual hub - this will throw not found if the resource does not exist
PSVirtualHub parentVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName);
if (parentVirtualHub == null)
var hubVnetConnection = new MNM.HubVirtualNetworkConnection(enableInternetSecurity: true);
hubVnetConnection.Name = this.Name;

if (this.EnableInternetSecurityFlag.HasValue && this.EnableInternetSecurityFlag.Value == false)
{
throw new PSArgumentException(Properties.Resources.ParentVirtualHubNotFound);
hubVnetConnection.EnableInternetSecurity = false;
}

PSHubVirtualNetworkConnection hubVnetConnection = new PSHubVirtualNetworkConnection();
hubVnetConnection.Name = this.Name;
hubVnetConnection.EnableInternetSecurity = this.EnableInternetSecurity.IsPresent;

//// Resolve the remote virtual network
//// Let's not try to resolve this since this can be in other RG/Sub/Location
if (ParameterSetName.Contains(CortexParameterSetNames.ByRemoteVirtualNetworkObject))
{
hubVnetConnection.RemoteVirtualNetwork = new PSResourceId() { Id = this.RemoteVirtualNetwork.Id };
hubVnetConnection.RemoteVirtualNetwork = new MNM.SubResource(this.RemoteVirtualNetwork.Id);
}
else if (ParameterSetName.Contains(CortexParameterSetNames.ByRemoteVirtualNetworkResourceId))
{
hubVnetConnection.RemoteVirtualNetwork = new PSResourceId() { Id = this.RemoteVirtualNetworkId };
hubVnetConnection.RemoteVirtualNetwork = new MNM.SubResource(this.RemoteVirtualNetworkId);
}

if (parentVirtualHub.VirtualNetworkConnections == null)
{
parentVirtualHub.VirtualNetworkConnections = new List<PSHubVirtualNetworkConnection>();
}

List<string> resourceIds = new List<string>();
resourceIds.Add(hubVnetConnection.RemoteVirtualNetwork.Id);
var auxHeaderDictionary = GetAuxilaryAuthHeaderFromResourceIds(resourceIds);
Expand All @@ -191,18 +190,13 @@ public override void Execute()
auxAuthHeader = new Dictionary<string, List<string>>(auxHeaderDictionary);
}

parentVirtualHub.VirtualNetworkConnections.Add(hubVnetConnection);

ConfirmAction(
Properties.Resources.CreatingResourceMessage,
this.Name,
() =>
{
WriteVerbose(String.Format(Properties.Resources.CreatingLongRunningOperationMessage, this.ResourceGroupName, this.Name));
this.CreateOrUpdateVirtualHub(this.ResourceGroupName, this.ParentResourceName, parentVirtualHub, parentVirtualHub.Tag, auxAuthHeader);
var createdVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName);

WriteObject(createdVirtualHub.VirtualNetworkConnections.FirstOrDefault(hubConnection => hubConnection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)));
WriteObject(this.CreateOrUpdateHubVirtualNetworkConnection(this.ResourceGroupName, this.ParentResourceName, this.Name, hubVnetConnection, auxAuthHeader));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,6 @@ public override void Execute()
this.Name = parsedResourceId.ResourceName;
}

//// Get the virtual hub - this will throw not found if the resource is invalid
PSVirtualHub parentVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName);

if (parentVirtualHub == null)
{
throw new PSArgumentException(Properties.Resources.ParentVirtualHubNotFound);
}

var connectionToRemove = parentVirtualHub.VirtualNetworkConnections.FirstOrDefault(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase));
if (connectionToRemove != null)
{
base.Execute();

ConfirmAction(
Expand All @@ -130,15 +119,13 @@ public override void Execute()
this.Name,
() =>
{
parentVirtualHub.VirtualNetworkConnections.Remove(connectionToRemove);
this.CreateOrUpdateVirtualHub(this.ResourceGroupName, this.ParentResourceName, parentVirtualHub, parentVirtualHub.Tag);
this.HubVirtualNetworkConnectionsClient.Delete(this.ResourceGroupName, this.ParentResourceName, this.Name);

if (PassThru)
{
WriteObject(true);
}
});
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,7 @@ public override void Execute()
this.Name = parsedResourceId.ResourceName;
}

//// Get the virtual hub - this will throw not found if the resource is invalid
PSVirtualHub parentVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName);

var connectionToModify = parentVirtualHub.VirtualNetworkConnections.FirstOrDefault(connection => connection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase));
var connectionToModify = this.HubVirtualNetworkConnectionsClient.Get(this.ResourceGroupName, this.ParentResourceName, this.Name);
if (connectionToModify == null)
{
throw new PSArgumentException(Properties.Resources.HubVnetConnectionNotFound);
Expand All @@ -141,10 +138,7 @@ public override void Execute()
this.Name,
() =>
{
this.CreateOrUpdateVirtualHub(this.ResourceGroupName, this.ParentResourceName, parentVirtualHub, parentVirtualHub.Tag, auxAuthHeader);
var updatedVirtualHub = this.GetVirtualHub(this.ResourceGroupName, this.ParentResourceName);

WriteObject(updatedVirtualHub.VirtualNetworkConnections.FirstOrDefault(hubConnection => hubConnection.Name.Equals(this.Name, StringComparison.OrdinalIgnoreCase)));
WriteObject(this.CreateOrUpdateHubVirtualNetworkConnection(this.ResourceGroupName, this.ParentResourceName, this.Name, connectionToModify, auxAuthHeader));
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Microsoft.Azure.Commands.Network
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using System.Linq;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;

[Cmdlet(VerbsCommon.New,
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualHub",
Expand Down Expand Up @@ -78,6 +79,8 @@ public class NewAzureRmVirtualHubCommand : VirtualHubBaseCmdlet
[ValidateNotNullOrEmpty]
public string Location { get; set; }

public const String ChangeDesc = "VirtualNetworkConnection parameter is deprecated. Use AzVirtualHubVnet commands";
[CmdletParameterBreakingChange("HubVnetConnection", ChangeDescription = ChangeDesc)]
[Parameter(
Mandatory = false,
HelpMessage = "The hub virtual network connections associated with this Virtual Hub.")]
Expand Down Expand Up @@ -152,34 +155,21 @@ public override void Execute()
Location = this.Location
};

virtualHub.VirtualNetworkConnections = new List<PSHubVirtualNetworkConnection>();
virtualHub.RouteTable = this.RouteTable;
virtualHub.RouteTables = new List<PSVirtualHubRouteTable>();

if (this.HubVnetConnection != null)
{
virtualHub.VirtualNetworkConnections = new List<PSHubVirtualNetworkConnection>();
virtualHub.VirtualNetworkConnections.AddRange(this.HubVnetConnection);

// get auth headers for cross-tenant hubvnet conn
List<string> resourceIds = new List<string>();
foreach (var connection in this.HubVnetConnection)
{
resourceIds.Add(connection.RemoteVirtualNetwork.Id);
}

var auxHeaderDictionary = GetAuxilaryAuthHeaderFromResourceIds(resourceIds);
if (auxHeaderDictionary != null && auxHeaderDictionary.Count > 0)
{
auxAuthHeader = new Dictionary<string, List<string>>(auxHeaderDictionary);
}
}

virtualHub.RouteTable = this.RouteTable;
virtualHub.RouteTables = new List<PSVirtualHubRouteTable>();

if (string.IsNullOrWhiteSpace(this.Sku))
{
virtualHub.Sku = "Standard";
}

WriteObject(this.CreateOrUpdateVirtualHub(
WriteObject(CreateOrUpdateVirtualHub(
this.ResourceGroupName,
this.Name,
virtualHub,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Microsoft.Azure.Commands.Network
using Microsoft.Azure.Commands.ResourceManager.Common.ArgumentCompleters;
using System.Linq;
using Microsoft.Azure.Management.Internal.Resources.Utilities.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;

[Cmdlet("Update",
ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualHub",
Expand Down Expand Up @@ -77,6 +78,8 @@ public class UpdateAzureRmVirtualHubCommand : VirtualHubBaseCmdlet
HelpMessage = "The address space string for this virtual hub.")]
public string AddressPrefix { get; set; }

public const String ChangeDesc = "VirtualNetworkConnection parameter is deprecated. Use AzVirtualHubVnet commands";
[CmdletParameterBreakingChange("HubVnetConnection", ChangeDescription = ChangeDesc)]
[Parameter(
Mandatory = false,
HelpMessage = "The hub virtual network connections associated with this Virtual Hub.")]
Expand Down Expand Up @@ -139,23 +142,29 @@ public override void Execute()
}

//// HubVirtualNetworkConnections
List<PSHubVirtualNetworkConnection> hubVnetConnectionList = null;
if (this.HubVnetConnection != null)
{
virtualHubToUpdate.VirtualNetworkConnections = new List<PSHubVirtualNetworkConnection>();
virtualHubToUpdate.VirtualNetworkConnections.AddRange(this.HubVnetConnection);

// get auth headers for cross-tenant hubvnet conn
List<string> resourceIds = new List<string>();
foreach (var connection in this.HubVnetConnection)
// Simulate behavior of old API to clear all existing connections not in new request and then add new ones
if (virtualHubToUpdate.VirtualNetworkConnections != null)
{
resourceIds.Add(connection.RemoteVirtualNetwork.Id);
foreach (var connection in virtualHubToUpdate.VirtualNetworkConnections)
{
if (!this.HubVnetConnection.Any(conn => conn.Name == connection.Name))
{
this.HubVnetConnectionCmdlet.HubVirtualNetworkConnectionsClient.Delete(this.ResourceGroupName, this.Name, connection.Name);
}
}
}

var auxHeaderDictionary = GetAuxilaryAuthHeaderFromResourceIds(resourceIds);
if (auxHeaderDictionary != null && auxHeaderDictionary.Count > 0)
{
auxAuthHeader = new Dictionary<string, List<string>>(auxHeaderDictionary);
}
virtualHubToUpdate.VirtualNetworkConnections = new List<PSHubVirtualNetworkConnection>();
virtualHubToUpdate.VirtualNetworkConnections.AddRange(this.HubVnetConnection);
}
else
{
// optimization to avoid unnecessary put on hubvnet connections
hubVnetConnectionList = virtualHubToUpdate.VirtualNetworkConnections;
virtualHubToUpdate.VirtualNetworkConnections = null;
}

//// VirtualHubRouteTable
Expand All @@ -176,12 +185,18 @@ public override void Execute()
() =>
{
WriteVerbose(String.Format(Properties.Resources.UpdatingLongRunningOperationMessage, this.ResourceGroupName, this.Name));
WriteObject(this.CreateOrUpdateVirtualHub(
var hubToReturn = this.CreateOrUpdateVirtualHub(
this.ResourceGroupName,
this.Name,
virtualHubToUpdate,
this.Tag,
auxAuthHeader));
auxAuthHeader);
if (hubVnetConnectionList != null)
{
// patch back the hubvnet connection for backward compatibility
hubToReturn.VirtualNetworkConnections = hubVnetConnectionList;
}
WriteObject(hubToReturn);
});
}
}
Expand Down
Loading