Skip to content

[AppGW] Adding probe, multisite and URl routing support #1433

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Dec 8, 2015
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
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.9.1.0\lib\net40\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.2-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.4-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="9.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="3.0.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="3.0.4-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5799.28345-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.4.0-preview" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,13 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Compute.9.1.0\lib\net40\Microsoft.Azure.Management.Compute.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.2-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.4-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.3.0.0\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.1.0\lib\dotnet\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
Expand All @@ -114,14 +112,18 @@
<HintPath>..\..\..\packages\Microsoft.IdentityModel.Clients.ActiveDirectory.2.18.206251556\lib\net45\Microsoft.IdentityModel.Clients.ActiveDirectory.WindowsForms.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime">
<Reference Include="Microsoft.Rest.ClientRuntime">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.1.4.1\lib\dotnet\Microsoft.Rest.ClientRuntime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.1.0\lib\dotnet\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime.Azure, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.Azure.2.1.0\lib\portable-net45+win8+wpa81\Microsoft.Rest.ClientRuntime.Azure.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Compute" version="9.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="3.0.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="3.0.4-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.9" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<Reference Include="Microsoft.Azure.Management.Authorization">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.3-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Reference Include="Microsoft.Azure.Management.Network, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.3.0.4-preview\lib\net45\Microsoft.Azure.Management.Network.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace Commands.Network.Test.ScenarioTests
{
public class ApplicationGatewayTests : RMTestBase
{
[Fact(Skip = "Rerecord tests")]
[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestApplicationGatewayCRUD()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,51 +20,70 @@ function Test-ApplicationGatewayCRUD
{
# Setup

$rgname = Get-ResourceGroupName
$rname = Get-ResourceName
$domainNameLabel = Get-ResourceName
$vnetName = Get-ResourceName
$publicIpName = Get-ResourceName
$vnetGatewayConfigName = Get-ResourceName
$rglocation = Get-ProviderLocation ResourceManagement
$resourceTypeParent = "Microsoft.Network/applicationgateways"
$location = Get-ProviderLocation $resourceTypeParent

$gipconfigname = Get-ResourceName
$fipconfigName = Get-ResourceName
$poolName = Get-ResourceName
$poolSettingName = Get-ResourceName
$frontendPortName = Get-ResourceName
$listenerName = Get-ResourceName
$ruleName = Get-ResourceName
$appgwName = Get-ResourceName
$rgname = "kagarg"
$vnetName = "vnet01"
$subnetName = "subnet01"
$publicIpName = "publicip01" 
$gipconfigname = "gatewayip01"
$fipconfigName = "frontendip01"
$poolName = "pool01"
$frontendPort01Name = "frontendport01"
$frontendPort02Name = "frontendport02"
$poolSetting01Name = "setting01"
$poolSetting02Name = "setting02"
$probeName ="probe01"
$listener01Name = "listener01"
$listener02Name = "listener02"
$rule01Name = "rule01"
$rule02Name = "rule02"
$appgwName = "appgw01"

try
{
# Create the resource group
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $rglocation -Tags @{Name = "testtag"; Value = "testval"}
$resourceGroup = New-AzureRmResourceGroup -Name $rgname -Location $location -Tags @{Name = "testtag"; Value = "PS testing app gw"}
      
# Create the Virtual Network
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24
$subnet = New-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
$vnet = New-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
$vnet = Get-AzureRmvirtualNetwork -Name $vnetName -ResourceGroupName $rgname
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name "GatewaySubnet" -VirtualNetwork $vnet

# Create the Application Gateway
$subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name $subnetName -VirtualNetwork $vnet

# Create public ip
$publicip = New-AzureRmPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Dynamic 

# Create application gateway configuration
$gipconfig = New-AzureRmApplicationGatewayIPConfiguration -Name $gipconfigname -Subnet $subnet
$pool = New-AzureRmApplicationGatewayBackendAddressPool -Name $poolName -BackendIPAddresses 1.1.1.1, 2.2.2.2, 3.3.3.3
$poolSetting = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSettingName -Port 80 -Protocol HTTP -CookieBasedAffinity Disabled
$fp = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPortName -Port 80
$fipconfig = New-AzureRmApplicationGatewayFrontendIPConfig -Name $fipconfigName -PublicIPAddress $publicip
$listener = New-AzureRmApplicationGatewayHttpListener -Name $listenerName -Protocol http -FrontendIPConfiguration $fipconfig -FrontendPort $fp
$rule = New-AzureRmApplicationGatewayRequestRoutingRule -Name $ruleName -RuleType basic -BackendHttpSettings $poolSetting -HttpListener $listener -BackendAddressPool $pool
$pool = New-AzureRmApplicationGatewayBackendAddressPool -Name $poolName -BackendIPAddresses 1.1.1.1, 2.2.2.2, 3.3.3.3
$fp01 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort01Name  -Port 80
$fp02 = New-AzureRmApplicationGatewayFrontendPort -Name $frontendPort02Name  -Port 8080
$probe = New-AzureRmApplicationGatewayProbeConfig -Name $probeName -Protocol Http -HostName "probe.com" -Path "/path/path.htm" -Interval 89 -Timeout 88 -UnhealthyThreshold 8
$poolSetting01 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting01Name -Port 80 -Protocol HTTP -CookieBasedAffinity Disabled -Probe $probe -RequestTimeout 66
$poolSetting02 = New-AzureRmApplicationGatewayBackendHttpSettings -Name $poolSetting02Name -Port 80 -Protocol HTTP -CookieBasedAffinity Disabled
$listener01 = New-AzureRmApplicationGatewayHttpListener -Name $listener01Name -Protocol http -FrontendIPConfiguration $fipconfig -FrontendPort $fp01
$listener02 = New-AzureRmApplicationGatewayHttpListener -Name $listener02Name -Protocol http -FrontendIPConfiguration $fipconfig -FrontendPort $fp02
$rule01 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule01Name -RuleType basic -BackendHttpSettings $poolSetting01 -HttpListener $listener01 -BackendAddressPool $pool
$rule02 = New-AzureRmApplicationGatewayRequestRoutingRule -Name $rule02Name -RuleType basic -BackendHttpSettings $poolSetting02 -HttpListener $listener02 -BackendAddressPool $pool
$sku = New-AzureRmApplicationGatewaySku -Name Standard_Small -Tier Standard -Capacity 2

$actual = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -BackendHttpSettingsCollection $poolSetting -FrontendIpConfigurations $fipconfig -GatewayIpConfigurations $gipconfig -FrontendPorts $fp -HttpListeners $listener -RequestRoutingRules $rule -Sku $sku
$expected = Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname
Compare-AzureRmApplicationGateway $actual $expected

Stop-AzureRmApplicationGateway -ApplicationGateway $expected
# Create Application Gateway
$appgw = New-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Location $location -BackendAddressPools $pool -Probes $probe -BackendHttpSettingsCollection $poolSetting01, $poolSetting02 -FrontendIpConfigurations $fipconfig  -GatewayIpConfigurations $gipconfig -FrontendPorts $fp01, $fp02 -HttpListeners $listener01, $listener02 -RequestRoutingRules $rule01, $rule02 -Sku $sku

# Get Application Gateway
$getgw =  Get-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname

# Start Application Gateway
Start-AzureRmApplicationGateway -ApplicationGateway $getgw

# Stop Application Gateway
Stop-AzureRmApplicationGateway -ApplicationGateway $getgw

# Delete Application Gateway
Remove-AzureRmApplicationGateway -Name $appgwName -ResourceGroupName $rgname -Force
}
finally
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<package id="Microsoft.Azure.Gallery" version="2.6.2-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Graph.RBAC" version="1.7.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Authorization" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="3.0.3-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="3.0.4-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Resources" version="2.18.7-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.5799.28345-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.4.0-preview" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,29 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
}
}

// Normalize Probe
if (applicationGateway.Probes != null)
{
foreach (var probe in applicationGateway.Probes)
{
probe.Id = string.Empty;
}
}

// Normalize BackendHttpSettings
if (applicationGateway.BackendHttpSettingsCollection != null)
{
foreach (var backendHttpSettings in applicationGateway.BackendHttpSettingsCollection)
{
backendHttpSettings.Id = string.Empty;

if (null != backendHttpSettings.Probe)
{
backendHttpSettings.Probe.Id = NormalizeApplicationGatewayNameChildResourceIds(
backendHttpSettings.Probe.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}
}
}

Expand Down Expand Up @@ -153,6 +170,38 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
}
}

// Normalize UrlPathMap
if (applicationGateway.UrlPathMaps != null)
{
foreach (var urlPathMap in applicationGateway.UrlPathMaps)
{
urlPathMap.Id = string.Empty;

urlPathMap.DefaultBackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
urlPathMap.DefaultBackendAddressPool.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);

urlPathMap.DefaultBackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
urlPathMap.DefaultBackendHttpSettings.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);

foreach (var pathRule in urlPathMap.PathRules)
{
pathRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
pathRule.BackendAddressPool.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);

pathRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
pathRule.BackendHttpSettings.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}
}
}

// Normalize RequestRoutingRule
if (applicationGateway.RequestRoutingRules != null)
{
Expand All @@ -165,15 +214,29 @@ public static void NormalizeChildResourcesId(PSApplicationGateway applicationGat
applicationGateway.ResourceGroupName,
applicationGateway.Name);

requestRoutingRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.BackendAddressPool.Id,
if (null != requestRoutingRule.BackendAddressPool)
{
requestRoutingRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.BackendAddressPool.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}

if (null != requestRoutingRule.BackendHttpSettings)
{
requestRoutingRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.BackendHttpSettings.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}

requestRoutingRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.BackendHttpSettings.Id,
if (null != requestRoutingRule.UrlPathMap)
{
requestRoutingRule.UrlPathMap.Id = NormalizeApplicationGatewayNameChildResourceIds(
requestRoutingRule.UrlPathMap.Id,
applicationGateway.ResourceGroupName,
applicationGateway.Name);
}
}
}
}
Expand Down
Loading