Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 17 additions & 0 deletions src/Network/Network.Test/ScenarioTests/ApplicationGatewayTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,23 @@ public void TestApplicationGatewayWithFirewallPolicy()
TestRunner.RunTestScript(string.Format("Test-ApplicationGatewayWithFirewallPolicy -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.nvadev_subset1)]
public void TestApplicationGatewayWithTCPResources()
{
TestRunner.RunTestScript(string.Format("Test-ApplicationGatewayWithTCPResources -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
}


[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.nvadev_subset1)]
public void TestApplicationGatewayWithTLSResources()
{
TestRunner.RunTestScript(string.Format("Test-ApplicationGatewayWithTLSResources -baseDir '{0}'", AppDomain.CurrentDomain.BaseDirectory));
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait(Category.Owner, NrpTeamAlias.nvadev_subset1)]
Expand Down
574 changes: 574 additions & 0 deletions src/Network/Network.Test/ScenarioTests/ApplicationGatewayTests.ps1

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Network.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using System;
using System.Linq;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApplicationGatewayBackendSetting"), OutputType(typeof(PSApplicationGateway))]
public class AddAzureApplicationGatewayBackendSettingsCommand : AzureApplicationGatewayBackendSettingsBase
{
[Parameter(
Mandatory = true,
ValueFromPipeline = true,
HelpMessage = "The applicationGateway")]
public PSApplicationGateway ApplicationGateway { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

var backendSettings = this.ApplicationGateway.BackendSettingsCollection.SingleOrDefault
(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));

if (backendSettings != null)
{
throw new ArgumentException("Backend settings with the specified name already exists");
}

backendSettings = base.NewObject();
this.ApplicationGateway.BackendSettingsCollection.Add(backendSettings);

WriteObject(this.ApplicationGateway);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Management.Automation;
using Microsoft.Azure.Commands.Network.Models;

namespace Microsoft.Azure.Commands.Network
{
public class AzureApplicationGatewayBackendSettingsBase : NetworkBaseCmdlet
{
[Parameter(
Mandatory = true,
HelpMessage = "The name of the backend settings")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "Port")]
[ValidateNotNullOrEmpty]
public int Port { get; set; }

[Parameter(
Mandatory = true,
HelpMessage = "Protocol")]
[ValidateSet("TCP", "TLS", IgnoreCase = true)]
[ValidateNotNullOrEmpty]
public string Protocol { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Timeout. Default value 30 seconds.")]
[ValidateNotNullOrEmpty]
public int Timeout { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "ID of the application gateway Probe")]
[ValidateNotNullOrEmpty]
public string ProbeId { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Application gateway Probe")]
[ValidateNotNullOrEmpty]
public PSApplicationGatewayProbe Probe { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Application gateway Trusted Root Certificates")]
[ValidateNotNullOrEmpty]
public PSApplicationGatewayTrustedRootCertificate[] TrustedRootCertificate { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Flag if host header should be picked from the host name of the backend server.")]
public SwitchParameter PickHostNameFromBackendAddress { get; set; }

[Parameter(
Mandatory = false,
HelpMessage = "Sets host header to be sent to the backend servers.")]
public string HostName { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

if (Probe != null)
{
this.ProbeId = this.Probe.Id;
}
}
public PSApplicationGatewayBackendSettings NewObject()
{
var backendSettings = new PSApplicationGatewayBackendSettings();
backendSettings.Name = this.Name;
backendSettings.Port = this.Port;
backendSettings.Protocol = this.Protocol;

if (0 == this.Timeout)
{
backendSettings.Timeout = 30;
}
else
{
backendSettings.Timeout = this.Timeout;
}

if (!string.IsNullOrEmpty(this.ProbeId))
{
backendSettings.Probe = new PSResourceId();
backendSettings.Probe.Id = this.ProbeId;
}

if (this.TrustedRootCertificate != null && this.TrustedRootCertificate.Length > 0)
{
backendSettings.TrustedRootCertificates = new List<PSResourceId>();
foreach (var trustedRootCert in this.TrustedRootCertificate)
{
backendSettings.TrustedRootCertificates.Add(
new PSResourceId()
{
Id = trustedRootCert.Id
});
}
}

if(this.PickHostNameFromBackendAddress.IsPresent)
{
backendSettings.PickHostNameFromBackendAddress = true;
}

if(this.HostName != null)
{
backendSettings.HostName = this.HostName;
}

backendSettings.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
this.NetworkClient.NetworkManagementClient.SubscriptionId,
Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewaybackendSettingsName,
this.Name);

return backendSettings;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Network.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApplicationGatewayBackendSetting"),OutputType(typeof(PSApplicationGatewayBackendSettings))]
public class GetAzureApplicationGatewayBackendSettings : NetworkBaseCmdlet
{
[Parameter(
Mandatory = false,
HelpMessage = "The name of the backend settings")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipeline = true,
HelpMessage = "The applicationGateway")]
public PSApplicationGateway ApplicationGateway { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

if (!string.IsNullOrEmpty(this.Name))
{
var backendSettings =
this.ApplicationGateway.BackendSettingsCollection.First(
resource =>
string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));

WriteObject(backendSettings);
}
else
{
var backendSettings = this.ApplicationGateway.BackendSettingsCollection;
WriteObject(backendSettings, true);
}

}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Network.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet("New", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApplicationGatewayBackendSetting"), OutputType(typeof(PSApplicationGatewayBackendSettings))]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this cmdlet will return ID like:
/subscriptions/{0}/resourceGroups/ResourceGroupNotSet/providers/Microsoft.Network/applicationGateways/ApplicationGatewayNameNotSet/{3}/{4}
can you please clarify in help message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New-AzApplicationGatewayBackendSetting it returns a PSApplicationGatewayBackendSettings Object
image

public class NewAzureApplicationGatewayBackendSettingsCommand : AzureApplicationGatewayBackendSettingsBase
{
public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
WriteObject(base.NewObject());
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// ----------------------------------------------------------------------------------
//
// 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.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Network.Models;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using System.Linq;
using System.Management.Automation;

namespace Microsoft.Azure.Commands.Network
{
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ApplicationGatewayBackendSetting"), OutputType(typeof(PSApplicationGateway))]
public class RemoveAzureApplicationGatewayBackendSettingsCommand : NetworkBaseCmdlet
{
[Parameter(
Mandatory = true,
HelpMessage = "The name of the backend settings")]
[ValidateNotNullOrEmpty]
public string Name { get; set; }

[Parameter(
Mandatory = true,
ValueFromPipeline = true,
HelpMessage = "The applicationGateway")]
public PSApplicationGateway ApplicationGateway { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

var backendSettings = this.ApplicationGateway.BackendSettingsCollection.SingleOrDefault
(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));

if (backendSettings != null)
{
this.ApplicationGateway.BackendSettingsCollection.Remove(backendSettings);
}

WriteObject(this.ApplicationGateway);
}
}
}
Loading