1

I am trying to deploy a multi-tenant application to azure using following standalone deployment strategy.

  1. Create a new database for each tenant in azure elastic pool.
  2. Create a new app service instance for each tenant.
  3. Map a custom domain name for the app service instance using a domain name which already has purchased from Azure (Ex: tenantname.mydomain.com)

I am trying to do this using following ARM template (To reduce the complexity I have mentioned only the related area of the template)

{
"$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'))]"
        ]
    }
]

}

Deployment fails with the error "A CNAME record pointing from mydomain.finapsl.com to {1} was not found. Alternative record awverify.mydomain.finapsl.com to awverify.finaptestwebsite2.azurewebsites.net was not found either."

Is it not possible to bind a custom domain name to an azure app service in this way? Your help is highly appreciated to solve this issue. I have been trying this more than two days.

1 Answers1

-2

Try this:

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

Also, verify your CNAME record (that error message is pretty specific) perhaps with a 3rd party tool like https://mxtoolbox.com/CNAMELookup.aspx

bmoore-msft
  • 8,376
  • 20
  • 22
  • 1
    bmoore-msft thank you for your valuable response. I still do no understand this verification process. Is that mean we cannot bind a domain name dynamically using ARM template? I want to bind a domain name as www.customeruniquename.mydomain.com. I can do this manually in azure portal after the web application deployment. but cannot do automatically via ARM templates. – Ajith Ramawickrama Sep 29 '18 at 14:48
  • you can do it in the template, but you need to make sure DNS is set up correctly (I had trouble with this myself). see if this helps: https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-custom-domain – bmoore-msft Oct 01 '18 at 22:40
  • I deployed hostNameBindings as separate template after the web site template deployment. So far its working without a problem. Appreciate your help. – Ajith Ramawickrama Oct 03 '18 at 06:20
  • github link is broken. Should have explained the answer here as well. – SergioL Sep 20 '21 at 17:11
  • I updated the link – bmoore-msft Sep 20 '21 at 18:05