通过代码
回答
Windows Azure网站管理REST API应提供您正在查找的功能。
属性Site.HostNames Windows Azure网站的属性可用于提供其他域名。这些属性可以在创建网站或更新时提供。
还请注意关于Configuring a custom domain name for a Windows Azure web site的一般信息。您还必须以编程方式将验证条目添加到您的DNS。
我不确定是否有任何用于网站管理API的包装SDK/libs/powershell命令行开关。
可以使用(Azure管理)Services API,Resources API或Azure RM PowerShell cmdlet完成此操作。
我发现使用Services API最简单,因为使用PowerShell登录Microsoft帐户时出现错误,以及为了使用Resources API需要创建Azure RM应用程序作为GlobalAdmin的荒谬需求。
PowerShell的
Login-AzureRmAccount # Non-automatable because pops up OAuth window. -Credentials parameter is broken.
Set-AzureRmWebapp -Name 'SiteName' -ResourceGroupName 'ResourceGroup' -HostNames @('SiteName.azurewebsites.net', ...)
服务REST API
需要客户端证书的请求。生成/下载新的认证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
需要全球性的管理员帐户(共同管理不工作)。按照说明here进行设置
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',...]
}
对于powershell命令至少你应该只包括自定义域而不是azurewebsites。净值,请参阅http://stackoverflow.com/questions/27830895/setting-host-names-for-azure-websites-via-azure-powershell, –
这是怎么回事,REST API信息在哪里? – AAlferez
破碎的dokumentation网址是一个非常不幸的情况。你究竟在做什么@ AnnArbor87?你可以看看似乎支持这些操作的xplat cli工具(例如https://github.com/Azure/azure-xplat-cli/blob/dev/lib/commands/asm/site.domain._js)通过Azure资源管理器。这可能意味着https://msdn.microsoft.com/en-us/library/azure/dn790568.aspx可能会提供所需的(现在是通用的)操作。 –
我在这里发布我的问题http://stackoverflow.com/questions/32789231/azure-update-resource-property-with-rest-api – AAlferez