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