Framework/Core/SVT/Services/TrafficManager.ps1

Set-StrictMode -Version Latest
class TrafficManager : SVTBase
{
    hidden [PSObject] $ResourceObject;

    TrafficManager([string] $subscriptionId, [string] $resourceGroupName, [string] $resourceName):
        Base($subscriptionId, $resourceGroupName, $resourceName)
    {
    }

    TrafficManager([string] $subscriptionId, [SVTResource] $svtResource):
        Base($subscriptionId, $svtResource)
    {
    }

    hidden [ControlResult] CheckTrafficManagerEndpointMonitorProtocol([ControlResult] $controlResult)
    {
        $trafficManagerProfile = Get-AzureRmTrafficManagerProfile -Name $this.ResourceContext.ResourceName `
                                -ResourceGroupName $this.ResourceContext.ResourceGroupName `
                                -ErrorAction Stop
        #Checking if endpoints are there or not in the profile
        if(($trafficManagerProfile.Endpoints | Measure-Object).Count -ne 0)
        {
            $EnabledEndpointList =  $trafficManagerProfile.Endpoints | Where-Object { $_.EndpointStatus -eq 'Enabled' }
            #check if all endpoints are not disabled
            if(($EnabledEndpointList | Measure-Object).Count -eq 0)
            {
                $controlResult.AddMessage([VerificationResult]::Passed,
                                        [MessageData]::new("All endpoints are disabled in the Traffic Manager profile ["+ $this.ResourceContext.ResourceName +"].")); 
            }
            else
            {
                if($trafficManagerProfile.MonitorProtocol -eq 'HTTPS')
                {
                    $controlResult.AddMessage([VerificationResult]::Passed,
                                        [MessageData]::new("The Traffic Manager profile ["+ $this.ResourceContext.ResourceName +"] is using HTTPS protocol for endpoint monitoring.")); 
                }
                else
                {
                    $controlResult.AddMessage([VerificationResult]::Failed,
                                        [MessageData]::new("The Traffic Manager profile ["+ $this.ResourceContext.ResourceName +"] is not using HTTPS protocol for endpoint monitoring.")); 
                }
            }
            
        }
        else
        {
            $controlResult.AddMessage([VerificationResult]::Passed,
                                        [MessageData]::new("No endpoints found in the Traffic Manager profile ["+ $this.ResourceContext.ResourceName +"].")); 
        }
        
 
        return $controlResult;    
    }
}