[Azure WebApp] Copy Production Slot into Staging Slot

Cosmin Stirbu 151 Reputation points
2021-08-23T09:13:47.747+00:00

Hello,

I'm trying to use https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/copy-production-slot however I'm receiving the following error:

Bad Request({"Code":"BadRequest","Message":"Clone into Production slot not supported.","Target":null,"Details":[{"Message":"Clone into Production slot not supported."},{"Code":"BadRequest"},{"ErrorEntity":{"ExtendedCode":"04237","MessageTemplate":"Clone into Production slot not supported.","Parameters":[],"Code":"BadRequest","Message":"Clone into Production slot not supported."}}],"Innererror":null})  

This is the actual call

az rest --method post --url https://management.azure.com/subscriptions/{...}/resourceGroups/{...}/providers/Microsoft.Web/sites/{...}/slotcopy?api-version=2019-08-01 --body "{\"targetSlot\": \"staging\"}"

Thank you,
Cosmin

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
6,690 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Cosmin Stirbu 151 Reputation points
    2021-11-04T07:07:36.587+00:00

    Based on a support ticket that I've opened on Azure the endpoint above doesn't exist any longer.

    As you can see, the URL takes you to a 404 page. https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/copy-production-slot

    The alternative mentioned in the support ticket is to use the following commands:

    $SrcSlot = Get-AzWebAppSlot -ResourceGroupName "test-rg" -Name "test-app" -Slot "production"  
    New-AzWebAppSlot -ResourceGroupName "test-rg" -Name "test-app" -SourceWebApp $SrcSlot -Slot "production-clone"  
    
    1 person found this answer helpful.
    0 comments No comments

  2. Grmacjon-MSFT 15,156 Reputation points
    2021-08-25T00:59:57.157+00:00

    Hi @Cosmin Stirbu ,

    The engineering team confirmed you can only copy from production to staging slots, or from a staging slot to another non-prod slot but not from staging into prod slot (which is why you're getting that error). It’s to prevent you from accidentally copying over your production config and losing it.

    The API you shared is there so you can copy content and config from one slot into a new slot, or after swapping into production, you can copy production content and config back into the staging environment.

    Hope that helps. Please let us know if you have further questions.

    -Grace


  3. jdomian 1 Reputation point
    2021-09-09T21:45:35.887+00:00

    This would be super helpful to in a sense duplicate a production slot as a new deploy slot. Right now we currently have to use a "dual FTP" browser I run on my local machine to simply copy production slots to deploy slots. This take a very long time and consumes bandwidth. Then that way we can make production pushes, test them in the deploy slot, then swap them out without any downtime and the ability to revert quick.

    I tried this and got the same error as above that "Clone into Production slot not supported." But I am not trying to clone "into" a production slot, I am trying to "Copy & Paste" production into a new slot with all of its contents to go with it.
    https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/copy-slot-slot#code-try-0