How to add multiple hostnames using az cli

I want to add multiple hostnames using az cli into app service, I am trying below command but it's only adding single hostname, is there any way to add multiple hostnames using single command, or is there any other command through which we can add multiple hostnames.

Command:

az webapp config hostname add --webapp-name  test --resource-group test123 --hostname testing.apetest.xyz --hostname testdns.apetest.xyz

Solution 1:

Using Azure CLI cmdlet az webapp config hostname add you can add only one host name to the web app in single execution.

Alternatively, You can use Set-AzWebApp PowerShell cmdlet, which has a string array parameter [-HostNames <String[]>] where you can pass & add multiple Hostnames to the web app.

Set-AzWebApp
   [-HostNames <String[]>]
   [-ResourceGroupName] <String>
   [-Name] <String>]

You can refer the below documentations for more information:

  • About the Set-AzWebApp cmdlet & list of allowed Parameters.
  • How to use Array of strings in PowerShell.