【问题标题】:How to bind custom domain name with Azure ARM template deployment如何将自定义域名与 Azure ARM 模板部署绑定
【发布时间】:2018-09-27 15:07:32
【问题描述】:

我正在尝试使用以下独立部署策略将多租户应用程序部署到 azure。

  1. 为 Azure 弹性池中的每个租户创建一个新数据库。
  2. 为每个租户创建一个新的应用服务实例。
  3. 使用已从 Azure 购买的域名(例如:tenantname.mydomain.com)为应用服务实例映射自定义域名

我正在尝试使用以下 ARM 模板(为了降低复杂性,我只提到了模板的相关区域)

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
    "sites_finaptestwebsite_name": {
        "defaultValue": "finaptestwebsite",
        "type": "String"
    },   
    "hostNameBindings_mydomain.finapsl.com_name": {
        "defaultValue": "mydomain.finapsl.com",
        "type": "String"
    },
    "hostNameBindings_finaptestwebsite.azurewebsites.net_name": {
        "defaultValue": "finaptestwebsite.azurewebsites.net",
        "type": "String"
    },
    "sites_finaptestwebsite_serverFarmId": {
        "defaultValue": "appServicePlanName",
        "type": "String"
    }
},
"variables": {},
"resources": [
    {
        "type": "Microsoft.Web/sites",
        "kind": "app",
        "name": "[parameters('sites_finaptestwebsite_name')]",
        "apiVersion": "2016-08-01",
        "location": "Central US",
        "scale": null,
        "properties": {
            "enabled": true,
            "hostNameSslStates": [
                {
                    "name": "[concat(parameters('sites_finaptestwebsite_name'),'.azurewebsites.net')]",
                    "sslState": "Disabled",
                    "virtualIP": null,
                    "thumbprint": null,
                    "toUpdate": null,
                    "hostType": "Standard"
                },
                {
                    "name": "[concat(parameters('sites_finaptestwebsite_name'),'.scm.azurewebsites.net')]",
                    "sslState": "Disabled",
                    "virtualIP": null,
                    "thumbprint": null,
                    "toUpdate": null,
                    "hostType": "Repository"
                },
                {
                    "name": "mydomain.finapsl.com",
                    "sslState": "Disabled",
                    "virtualIP": null,
                    "thumbprint": null,
                    "toUpdate": null,
                    "hostType": "Standard"
                }
            ],
            "serverFarmId": "[parameters('sites_finaptestwebsite_serverFarmId')]",
            "reserved": false,
            "siteConfig": null,
            "scmSiteAlsoStopped": false,
            "hostingEnvironmentProfile": null,
            "clientAffinityEnabled": true,
            "clientCertEnabled": false,
            "hostNamesDisabled": false,
            "containerSize": 0,
            "dailyMemoryTimeQuota": 0,
            "cloningInfo": null
        },
        "dependsOn": []
    },
    {
        "type": "Microsoft.Web/sites/hostNameBindings",
        "name": "[concat(parameters('sites_finaptestwebsite_name'), '/', parameters('hostNameBindings_finaptestwebsite.azurewebsites.net_name'))]",
        "apiVersion": "2016-08-01",
        "location": "Central US",
        "scale": null,
        "properties": {
            "siteName": "finaptestwebsite",
            "domainId": null,
            "hostNameType": "Verified"
        },
        "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('sites_finaptestwebsite_name'))]"
        ]
    },
    {
        "type": "Microsoft.Web/sites/hostNameBindings",
        "name": "[concat(parameters('sites_finaptestwebsite_name'), '/', parameters('hostNameBindings_mydomain.finapsl.com_name'))]",
        "apiVersion": "2016-08-01",
        "location": "Central US",
        "scale": null,
        "properties": {
            "siteName": "finaptestwebsite",
            "domainId": null,
            "azureResourceName": "finaptestwebsite",
            "azureResourceType": "Website",
            "customHostNameDnsRecordType": "CName",
            "hostNameType": "Managed"
        },
        "dependsOn": [
            "[resourceId('Microsoft.Web/sites', parameters('sites_finaptestwebsite_name'))]"
        ]
    }
]

}

部署失败并出现错误“找不到从 mydomain.finapsl.com 指向 {1} 的 CNAME 记录。找不到替代记录 awverify.mydomain.finapsl.com 到 awverify.finaptestwebsite2.azurewebsites.net要么。

这种方式不能将自定义域名绑定到azure app服务吗? 非常感谢您帮助解决此问题。我已经尝试了两天多了。

【问题讨论】:

    标签: azure azure-resource-manager azure-deployment azure-resource-group


    【解决方案1】:

    试试这个:

    https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.web/web-app-custom-domain-and-ssl

    另外,可以使用https://mxtoolbox.com/CNAMELookup.aspx 等第三方工具验证您的 CNAME 记录(该错误消息非常具体)

    【讨论】:

    • bmoore-msft 感谢您的宝贵回复。我还是不明白这个验证过程。这是否意味着我们不能使用 ARM 模板动态绑定域名?我想绑定一个域名为 www.customeruniquename.mydomain.com。 Web 应用程序部署后,我可以在 Azure 门户中手动执行此操作。但不能通过 ARM 模板自动执行。
    • 您可以在模板中执行此操作,但您需要确保 DNS 设置正确(我自己也遇到了问题)。看看这是否有帮助:docs.microsoft.com/en-us/azure/app-service/…
    • 在网站模板部署之后,我将 hostNameBindings 部署为单独的模板。到目前为止,它的工作没有问题。感谢您的帮助。
    • github 链接已损坏。也应该在这里解释答案。
    • 我更新了链接
    猜你喜欢
    • 2019-10-01
    • 2019-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-20
    • 2020-11-04
    相关资源
    最近更新 更多