Framework/Core/FixControl/Services/TrafficManagerFix.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
Set-StrictMode -Version Latest 

class TrafficManagerFix: FixServicesBase
{
    [PSObject] $ResourceObject = $null;

    TrafficManagerFix([string] $subscriptionId, [ResourceConfig] $resourceConfig, [string] $resourceGroupName): 
        Base($subscriptionId, $resourceConfig, $resourceGroupName) 
    { }

    [MessageData[]] EnableHttpsAsMonitorProtocol([PSObject] $parameters)
    {
        [MessageData[]] $detailedLogs = @();
        $detailedLogs += [MessageData]::new("Enabling 'HTTPS' protocol for endpoint monitoring on Traffic Manager Profile [$($this.ResourceName)]...");
        $TrafficManagerProfile = Get-AzTrafficManagerProfile -Name  $this.ResourceName -ResourceGroupName $this.ResourceGroupName 
        $TrafficManagerProfile.MonitorProtocol = 'HTTPS'
        if([string]::IsNullOrWhiteSpace($TrafficManagerProfile.MonitorPath))
        {
            $TrafficManagerProfile.MonitorPath='/'
        }
        Set-AzTrafficManagerProfile -TrafficManagerProfile $TrafficManagerProfile
        $detailedLogs += [MessageData]::new("'HTTPS' protocol is enabled for endpoint monitoring on Traffic Manager Profile [$($this.ResourceName)]");
        return $detailedLogs;
    }

}