0

I have an Azure Function App with two deployment slots. Is there a PowerShell command to swap deployment slots with preview?

enter image description here

user989988
  • 3,006
  • 7
  • 44
  • 91

1 Answers1

0

After reproducing from our end, you can use the below powershell commands to swap the slots with preview.

Switch-AzWebAppSlot -ResourceGroupName $rg -Name $site -SourceSlotName staging -DestinationSlotName production -SwapWithPreviewAction ApplySlotConfig

the above command applies the current staging slot's setting values to the target slot

and then use the below command to finish the swap

Switch-AzWebAppSlot -ResourceGroupName $rg -Name $site -SourceSlotName staging -DestinationSlotName production -SwapWithPreviewAction CompleteSlotSwap

REFERENCES:

  1. manage Azure Web App Deployment Slots
  2. Azure Powershell script to swap Azure App Service deployment slots
SwethaKandikonda
  • 7,513
  • 2
  • 4
  • 18
  • I have Azure Function Apps. Could I use these commands for function apps? – user989988 Jun 09 '22 at 23:43
  • I tried the above commands however app settings are set incorrectly. When I swap with preview via Azure Portal, app settings are set correctly. Why is that? – user989988 Jun 10 '22 at 23:28
  • How do I verify that 1st command has run successfully before running the above 2nd command in PowerShell? – user989988 Jun 13 '22 at 22:28
  • @user989988, after performing the first command you can check with ```$stagingSite = Get-AzWebAppSlot -ResourceGroupName $rg -Name $site -Slot staging $stagingSite.SiteConfig.AppSettings``` and see the app setting values have changed. – SwethaKandikonda Jun 13 '22 at 23:55