Export/Private/New-ApplicationGatewayHttpSettings.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
function Global:New-ApplicationGatewayHttpSettings {
    <#
    .SYNOPSIS
    ...
     
    .EXAMPLE
    ...
     
    .PARAMETER xxx
    ...
    #>

    [CmdletBinding()]    
    param
    (
        [Parameter(Mandatory = $true)]
        $Environments,
        [Parameter(Mandatory = $true)]
        $Probes,
        [Parameter(Mandatory = $false)]
        [switch]
        $IncludeSsl
    )
    process {
        Write-Verbose "Adding HttpSettings..."
        $HttpSettings = @{
            General    = $null
            Webclients = @{ }
            Collection = @()
        }        
        $HttpSettings.General = New-AzApplicationGatewayBackendHttpSetting -Name "HttpGeneral_Port80" -Port 80 -Protocol "Http" -Probe $Probes.General -CookieBasedAffinity "Disabled" -WarningAction SilentlyContinue                
        $HttpSettings.Collection += $HttpSettings.General
        # TODO: Get-Environments, add Probes per Path (e.g. -Path "/BCDefault-Web")
        foreach ($environment in $Environments) {
            $ProbeWebclient = $Probes.Webclients[$environment.ServerInstance]
            $HttpSettingWebclient = New-AzApplicationGatewayBackendHttpSetting -Name "HttpWebclient_Port8080_$($environment.ServerInstance)"  -Port 8080 -Protocol "Http" -CookieBasedAffinity "Enabled" -AffinityCookieName "WebclientApplicationGatewayAffinity" -Probe $ProbeWebclient -WarningAction SilentlyContinue            
            $HttpSettings.Webclients.Add($environment.ServerInstance, $HttpSettingWebclient)
            $HttpSettings.Collection += $HttpSettingWebclient
        }
        $HttpSettings
    }
}