Search code examples
azurepowershellazure-web-app-serviceazure-powershellazure-cli

Azure Webapp Clone powershell script is not working


I want to copy an existing webapp to another app plan. I have collected the command from https://learn.microsoft.com/en-us/azure/app-service/app-service-web-app-cloning

But getting ##[error]Long running operation failed with status 'InternalServerError'. error when i am trying to run webapp cloning script.

Here is my script,

$srcapp = Get-AzWebApp -ResourceGroupName abcd -Name Testapp1

$destapp = New-AzWebApp -ResourceGroupName abcd -Name Testapp2 -Location "West Europe" -AppServicePlan appplan-1 -SourceWebApp $srcapp

Didn't find anything helpful on the web. Can anyone help please?

enter image description here


Solution

  • We have tried the same script that you are using based on the given Microsoft Document in Question.

    The command you are trying ,which can create the new app in the West Europe region, and tie it to an existing App Service Plan .

    NOTE:- We are using an existing Appservice plan which is P1V2 with West Europe location.

    Same error as you are getting:-

    enter image description here

    Tried to az logout & az login again and runned the script worked fine.

    Also make sure that you have provided the App service file path as shown below.To get the path (APP SERVICE PLAN> PROPERTIES>RESOURCEID(COPY&USE)).

    $destapp = New-AzWebApp -ResourceGroupName RGNAME -Name appajtest13 -Location "West Europe" -AppServicePlan "subscriptions/subscriptionID/resourcegroups/my resourcegroup/providers/Microsoft.Web/serverFarms/existingappserviceplanname" -SourceWebApp $srcapp
    

    SUCCESFULLY CREATED OUTPUT DETAILS:-

    enter image description here

    enter image description here

    The PowerShell & az version which we are using as shown below:

    enter image description here enter image description here

    For more information you can refer this SO THREAD|Why won't my app service clone properly on Azure as suggested by @AjayKumar-MSFT.