Welcome to the Microsoft Q&A Platform. Thank you for reaching out & I hope you are doing well.
There are couple of problems with your approach
- Azure App Service/WebApps do not hold any property that identifies whether it is serving requests behind an AFD or not.
- Similarly, AFD does not have any property to verify if the Origin is an Azure Service or a Third party service, at least not directly. However, AFD does have a property where is stores the backends' HostName, which we are going to utilize
Use the below script to list the Azure App Services that that are being added as an AFD's origin.
$resourceGroupName = "<RG Name>"
#Get All AFDs in this ResourceGroup
$frontdoors = Get-AzFrontDoorCdnProfile -ResourceGroupName $resourceGroupName
$i = 1
#Loop through the AFDs
foreach ($frontdoor in $frontdoors){
#Get all the OriginGroups in an AFD
$origingroups = Get-AzFrontDoorCdnOriginGroup -ResourceGroupName $frontdoor.ResourceGroupName -ProfileName $frontdoor.Name
#Loop through the OriginGroups
foreach ($origingroup in $origingroups){
#Get all the Origins in an OriginGroup
$origins = Get-AzFrontDoorCdnOrigin -ResourceGroupName $origingroup.ResourceGroupName -ProfileName $frontdoor.Name -OriginGroupName $origingroup.Name
#Loop through the OriginS
foreach ($origin in $origins){
#Check whether the Host Header contains *.azurewebsites.net, indicating whether this is a App Service or not
if($origin.OriginHostHeader.Contains(".azurewebsites.net"))
{
Write-Output $i
$i = $i+1
Write-Host -NoNewline $frontdoor.Name " in ResourceGroup " $frontdoor.ResourceGroupName " contains "$origin.OriginHostHeader
Write-Output ""
}
}
}
}
Points to Note:
- The above script is for Azure App Services.
- For other Azure PaaS services, you have to use appropriate OriginHostHeader value or a different identifying property as per the use case
- As stated, neither of the services have any indicating feature/property to indicate that it is being used along the other service. The above is just a work around exploiting Host Header name.
Kindly let us know if this helps or you need further assistance on this issue.
Thanks,
Kapil
Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.