Michael B
Michael B

Reputation: 12228

Specifying web app domain name in resource manager template

I am currently trying to create Resource Manager Template files for azure web apps. Nothing complicated initially, just deploying a website from a GitHub template

As the raw template it works fine, however now I am trying to make it automatically attach the domain name. This is the relevant section of the resource file:

"apiVersion": "2015-04-01",
"name": "TDtestSimpleSiteWP",
"type": "Microsoft.Web/sites",
"location": "West Europe",
"dependsOn": [
  "[resourceId('Microsoft.Web/serverfarms', 'TDtestSimpleSiteSP')]"
],
"properties": {
  "serverFarmId": "TDtestSimpleSiteSP",
  "hostnames": [
    "www.example.uk",
      "tdtestSimpleSitewp.azurewebsites.net"
  ],
  "enabledHostNames": [
    "www.example.uk",
      "tdtestSimpleSitewp.azurewebsites.net",
      "tdtestSimpleSitewp.scm.azurewebsites.net"
  ],
},

the enabledHostNames section is the latest addition to test if that made any difference, it didn't. Neither did adding a hostNameSslStates.

The error I am now receiving is:

'There are no host names which could be used for validation.'

If I add the site through the portal it accepts the DNS validation is done, so I know its not a DNS issue.

I have looked through the relevant schema but can't find anything there that looks relevant.

Any thoughts?

Upvotes: 3

Views: 2354

Answers (3)

Mark Hijdra
Mark Hijdra

Reputation: 126

Was currently doing some research for this, and found out that it can be done.

Variables

"webSiteName": "yourawesomewebapp"
"customDomain": "www.example.com"

Template

{
  "name": "[concat(variables('webSiteName'),'/',variables('customDomain'))]",
  "apiVersion": "2015-08-01",
  "type": "Microsoft.Web/sites/hostNameBindings",
  "location": "West Europe",
  "dependsOn": [
    "[concat('Microsoft.Web/sites/', variables('webSiteName'))]"
  ],
  "properties": {
    "siteName": "[variables('webSiteName')]",
    "domainId": null,
    "hostNameType": "Verified"
  }
}

Try https://resources.azure.com/ for a stripped down RM/JSON azure portal, very useful for stuff like this.

Upvotes: 7

Lech Migdal
Lech Migdal

Reputation: 3984

I was getting the same error when deploying sites with websites behind a traffic manager. Template exported from portal included traffic manager endpoints in hostnames and enabledHostNames. After removing them - everything was created and proper entries (from traffic manager) were added automatically by Azure to hostnames.

I know that this question is old, but maybe my experience will help someone :)

Upvotes: 4

Suneet Nangia
Suneet Nangia

Reputation: 1670

This may help, looks like it is not supported to create the external binding at the time of web app creation but could be done as a second step...

https://social.msdn.microsoft.com/Forums/azure/en-US/59767145-36bd-45c3-ace8-f773538532bd/writing-arm-template-for-web-app-with-specified-hostnames-and-hostnamesslstates?forum=windowsazurewebsitespreview&prof=required

Upvotes: 4

Related Questions