Reputation: 12228
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
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
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
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...
Upvotes: 4