Search code examples
azureazure-devopsazure-web-app-serviceazure-webapps

how to fix 'conflicts with an already existing hostname' while cloning web app using Azure cloudshell


Scenario: You want to clone an app to another region, while configuring an Azure Resource Manager traffic manager profile that includes both apps.

Below are the commands I tried

$srcapp = Get-AzWebApp -ResourceGroupName SourceAzureResourceGroup -Name 
source-webapp

$destapp = New-AzWebApp -ResourceGroupName DestinationAzureResourceGroup -Name dest-webapp -Location "South Central US" -AppServicePlan DestinationAppServicePlan -SourceWebApp $srcapp -TrafficManagerProfileName newTrafficManagerProfile

the above commands fail with ""Creating app with backup from 'subscriptiondetailshere' failed: Detail: Hostname \'abc.xyz.companydomain.com\' conflicts with an already existing hostname. ExtendedCode: 04005"

FYI : the apps are hosted in standard app service plan. I did read documentation saying only the premium apps can be cloned but I was able to clone this particular app in standard plan through Azure Portal UI.

I want to be able to automate this using the ps. Any pointers are appreciated

https://learn.microsoft.com/en-us/azure/app-service/app-service-web-app-cloning


Solution

  • Update:

    copied web app:

    enter image description here

    Traffic manager:enter image description here


    First, azure web app clone does support standard app service plan. Here is a screenshot from the doc:

    enter image description here

    Second, the code you're using is correct, I did a test at my side, it's working fine(The web app is copied from central us to west us, after copied, everything is working fine):

    enter image description here

    For the conflicting error, you should check in your destination resource group if there is a existing web app with that host name(you mentioned that you can copy from azure portal, maybe you didn't delete it when you were using code to copy it).