具有多个自定义域的Azure网站应用程序

时间:2017-06-03 19:24:24

标签: azure azure-web-sites

我在Azure中设置了一个Web应用服务。使用默认的自动生成名称,它可以正常工作。

我需要添加几个我购买的自定义域名。我们说domain1.com,domain2.com等等。

我去了我的App Service>自定义域> +添加主机>验证domain1.com succesfuly。我点击了“添加主机名”按钮,并且domain1.com已成功添加到我的Azure Web App中。

问题是,当我按照所有相同的步骤添加domain2.com时,Azure警报声明domain2.com已成功添加,但事实上它根本没有添加。

我现在试了几次。它总是说已添加,但第二个域名并未与第一个域名一起列出。

有什么想法吗?

谢谢!!

1 个答案:

答案 0 :(得分:2)

根据您的说明,我已将多个自定义域映射到我的网络应用。效果很好,结果如下:

enter image description here

我建议您尝试其他方式(使用代码或powershell)列出您当前的网络应用的主机名。

如果主机名已经设置,但门户网站没有显示,我建议您首先刷新您的网络浏览器。如果此操作无效,我建议您将反馈发送给azure支持团队,并通过代码或powershell删除主机名。最后,您可以尝试再次绑定主机名。

有关如何列出主机名并按代码删除主机名的更多详细信息(使用可从Nuget下载的azure management fluent api),您可以参考以下代码:

使用这种方式,首先需要创建Azure Active Directory应用程序和服务主体。生成服务主体后,您可以获取applicationid,访问密钥和talentid。更多细节,您可以参考此article

  string subscription = "subscriptionid";
            string client = "clientid";
            string key = "clientkey";
            string tenant = "tenantid";

            var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(client,key,tenant,AzureEnvironment.AzureGlobalCloud);

            var azure = Azure
                .Configure()
                .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                .Authenticate(credentials)
                .WithDefaultSubscription();

            //List the hostname
            var resut = azure.WebApps.GetByResourceGroup("ResourceGroupName", "WebappName").EnabledHostNames; ;



            var app1 = azure.WebApps.GetByResourceGroup("ResourceGroupName", "WebappName");

            //Delete the hostname
            app1 = app1.Update().WithoutHostnameBinding("yourCustomDomain").Apply();

结果:enter image description here

相关问题