function CheckFrontDoorEndPoints() {
    param(
    [Parameter(Mandatory)]
     [Microsoft.Azure.Commands.Profile.Models.Core.PSAzureContext]$subscription,
     [Parameter(Mandatory)]
     [Microsoft.Azure.Commands.FrontDoor.Models.PSFrontDoor[]] $frontDoors,
     [Parameter(Mandatory)]
     [string]$effectoryDomainPattern
    )
    [EffectoryDomainNameCheck[]]$Result = @()
    
    foreach($frontDoor in $frontDoors) {
        $resource = Get-AzResource -ResourceId $frontDoor.Id

        if ($endPointHostNames = $frontDoor.FrontendEndpoints | Where-Object HostName -like $effectoryDomainPattern) {
            foreach ($endPoint in $endPointHostNames) {
                # frontdoor
                $domainNameCheck = [EffectoryDomainNameCheck] @{
                    SubscriptionId = $subscriptionId; 
                    SubscriptionName = $subscription.Name;
                    ResourceId = $endPoint.Id;
                    ResourceName = $endPoint.Name;
                    ResourceType = $endPoint.Type;
                    ResourceGroupName = $resource.ResourceGroupName;
                    DomainName = $endPoint.HostName;
                    Tag_Team = $resource.Tags.team
                    Tag_Product = $resource.Tags.product
                    Tag_Environment = $resource.Tags.environment
                    Tag_Data = $resource.Tags.data
                }
            $Result += $domainNameCheck
        }  }
    }

    $Result
}