如何将自定义域名与Azure ARM模板部署绑定

时间:2018-09-27 15:07:32

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

我正在尝试使用以下独立部署策略将多租户应用程序部署为天蓝色。

  1. 为天蓝色弹性池中的每个租户创建一个新数据库。
  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应用程序服务? 非常感谢您的帮助以解决此问题。我已经尝试了两天以上。

1 个答案:

答案 0 :(得分:0)

尝试一下:https://github.com/Azure/azure-quickstart-templates/tree/master/201-web-app-custom-domain

另外,也许使用https://mxtoolbox.com/CNAMELookup.aspx

之类的第三方工具来验证您的CNAME记录(该错误消息非常明确)。