How do I programmatically add an additional domain name to an Azure Web Site?
Hopefully there .NET API for this that I missed, perhaps in the Azure SDK or a NuGet package. Or perhaps there is a REST interface.
How do I programmatically add an additional domain name to an Azure Web Site?
Hopefully there .NET API for this that I missed, perhaps in the Azure SDK or a NuGet package. Or perhaps there is a REST interface.
The Windows Azure Web Sites Management REST API should provide the functionality you are looking for.
The property Site.HostNames property of Windows Azure Web Site can be used to provide additional domain names. The properties can be provided during creation of a web site or when updating.
Please also take note of the general info on Configuring a custom domain name for a Windows Azure web site. You would also have to programmatically add the verification entry to your DNS.
I am not sure if there are any wrapper SDKs/libs/powershell commandlets for the web sites management API.
This can be done using either the (Azure Management) Services API, the Resources API, or the Azure RM PowerShell cmdlets.
I find using the Services API easiest, because of bugs with logging in with Microsoft accounts with PowerShell, and the absurd requirement of needing to create an Azure RM app as a GlobalAdmin in order to use the Resources API.
PowerShell
Login-AzureRmAccount # Non-automatable because pops up OAuth window. -Credentials parameter is broken.
Set-AzureRmWebapp -Name 'SiteName' -ResourceGroupName 'ResourceGroup' -HostNames @('SiteName.azurewebsites.net', ...)
Services REST API
Requires Client Certificate in request. Generate/download new certificates here
PUT https://management.core.windows.net:8443/{subscriptionId}/services/webspaces/{webspace}/sites/{siteName}
Accept: application/json
Content-Type: application/json
x-ms-version: 2015-04-01
{
HostNames: ['siteName.azurewebsites.net',...]
}
Resources REST API
Requires Global Administrator account (Co-Admin does not work). Follow instructions here for setup
PUT https://management.azure.com/subscriptions/<subscriptionId>/resourcegroups/resourceGroup>/providers/Microsoft.Web/sites/<siteName>?api-version=2015-04-01
Accept: application/json
Content-Type: application/json
{
HostNames: ['siteName.azurewebsites.net',...]
}