Search code examples
azure-api-appsazure-deployment

Deploy a resource group with App Service


I have published an API app from Visual Studio to a new resource group, also created an App Service Plan, so after the deployment the resource group contains 2 items:

  • AppServicePlan1
  • AppService1

Now I am trying to deploy these items to another resource group as follows:

  • Select 'Automation script' in the resource group settings
  • Click 'Deploy'
  • Select 'Create new' resource group, enter its name
  • Enter 'Serverfarms_AppServicePlan1_name' parameter value (new app service plan name, e.g. AppServicePlan2)
  • Enter 'Sites_AppService1_name' parameter value (new app service name, e.g. AppService2)
  • Tick 'Agree to terms and conditions'
  • Click 'Puchase'

The process fails with the following error message:

"The host name AppService1.azurewebsites.net is already assigned to another Azure website: AppService1."

I have tried different things - deploying app service plan, logic apps, etc. from one resource group to another works fine, but deploying an app service fails as described above.

I have tried changing the hostNames property in the template file to ["AppService2.azurewebsites.net"] manually - I'm not getting the error then (although I'm not sure, maybe something else also needs to be changed, e.g. properties enabledHostNames, hostNameSslStates?) and the deployment seems to work, however the 'deployed' app service can't be used as it contains only 1 file - hostingstart.html.

What am I missing?


Solution

  • I think you have everything correct - as you noticed when you use the generated automation script it will create everything with the same properties that currently exist. We try to parameterize the correct value (like the web app name) but there are some details that can be overlooked (like host names). After changing all that it sounds like you got it to deploy.

    The "code" however is not part of the automation script - only the infrastructure and configuration. So you still need to deploy your app to have it be identical. You can folder app deployment into the JSON template (using webdeploy or github) but since that requires access to external artifacts, that's not done automatically.

    That help?