Get all the custom domains of an Azure web app

Another one of those “this would be easier with PowerShell” moments. Maybe I’m becoming a real sys admin 🙂 I have an Azure app with a lot of custom domain names added to it and I needed to get those hostnames in a list. Using the web portal I could try and copy and paste them into a text file, but that’s the old “senior” Mike. New Mike uses the power of the shell. (Actually I’ve been using PowerShell for years now, but sometimes I revert to old lazy Mike). The problem with this is that Get-AzureRmWebApp outputs a list you cannot pipe to another command. So where I would normally think Get-AzureRmWebApp | where {$_.SiteName -eq “AzureAppName”} would work, it doesn’t. What you need to do is put those apps in a variable and then grab what you want from there. Like so.


$VariableName = Get-AzureRmWebApp -Name "AzureAppName"

$cvproddashboard.HostNames > AppNameHostNames.txt

notepad .\AppNameHostNames.txt

This particular app I was getting the hostnames for has 382 of them. By the way, Azure has a limit of 500. Guess how I figured that out 🙂 ?

Leave a Comment

Your email address will not be published.