7

I'm migrating a pretty serious multi-tenant application to Azure, and one of the challenges I see coming is that it hosts over a hundred domains.

On the Azure side, the only way I see to add a custom domain is hand-entering them via the portal. I would really like to script this out with Azure PowerShell or (perhaps less desirable for this one-off operation) one of the .Net APIs.

I did find this, which shows that it can be done with one of the REST APIs: Add a domain to an Azure web site via code

Is there anything for PowerShell?

Community
  • 1
  • 1
Brian MacKay
  • 31,133
  • 17
  • 86
  • 125

1 Answers1

8

you can use -

Set-AzureWebsite -Name "ramisample" -HostNames @('www.abc.com', 'abc.com')

Make sure you point the CNAME records before adding them as domains.

ramiramilu
  • 17,044
  • 6
  • 49
  • 66
  • Nice!... Wow I spent hours last night solving this with the REST API, this would have been so much easier. Quick question for the kids at home: I'm guessing if you have a hostname or two set up already, you better include them in your list or they will be lost. That's how the REST API works. – Brian MacKay Jan 12 '14 at 04:22
  • Strange... I can use the Set-AzureWebsite cmdlet to set properties such as -PhpVersion and -AppSettings, but trying to set HostNames does not work. It doesn't report failure, it just doesn't make the setting. I can manually set the same domains in the management portal just fine. – dprothero Apr 30 '15 at 17:48
  • Found the answer: http://stackoverflow.com/questions/27830895/setting-host-names-for-azure-websites-via-azure-powershell – dprothero Apr 30 '15 at 17:53
  • How can you accomplish this with azurerm? – sammarcow Oct 19 '17 at 14:57