Adding a domain to an Azure site through code

How to programmatically add an additional domain name to an Azure website?

Hopefully I skipped the .NET API for this, perhaps in the Azure SDK or NuGet. Or maybe there is a REST interface.

+4
sdk azure-web-sites
source share
2 answers

The Windows Azure Web Site Management REST API should provide the functionality you are looking for.

The Site.HostNames property of the Windows Azure Web Site property can be used to provide additional domain names. Properties may be provided at the time the website is created or when it is updated.

Also take a look at the general information about Configuring a custom domain name for a Windows Azure website . You will also need to programmatically add a validation record to your DNS.

I'm not sure if there are any SDK / libs / powershell shell commands for the website management API.

+3
source share

You can do this using either the Azure Management Services API, the Resource API, or the Azure RM PowerShell cmdlets.

I find using the service APIs the easiest because of logon errors with Microsoft accounts using PowerShell and the absurd need to create an Azure RM application as GlobalAdmin to use the resource APIs.

Powerhell

Login-AzureRmAccount # Non-automatable because pops up OAuth window. -Credentials parameter is broken. Set-AzureRmWebapp -Name 'SiteName' -ResourceGroupName 'ResourceGroup' -HostNames @('SiteName.azurewebsites.net', ...) 

REST Services API

A customer certificate is required upon request. Create / upload 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',...] } 

REST API Resource

A global administrator account is required (the shared administrator does not work). Follow the instructions here to configure

 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',...] } 
0
source share

All Articles