Switch-AzureRmWebAppSlot can't cancel a swap if the slot has been deleted [Need to support cancel Swap if a two phase swap is initiated] #3667
Description
Cmdlet(s)
Switch-AzureRmWebAppSlot
PowerShell Version
5.1.14393.953
Module Version
AzureRM.WebSites 2.5.0
OS Version
Azure Automation/Windows 10
Description
Consider the following scenario:
- You create a new slot
- You initiate a swap with preview process (Switch-AzureRmWebAppSlot -SwapWithPreviewAction ApplySlotConfig)
- The new slot get's deleted for whatever reason
You know have a "lingering" swap process. You can run "Switch-AzureRmWebAppSlot -SwapWithPreviewAction ResetSlotSwap" but it has no effect whatsoever (doesn't throw any errors though). Doesn't matter if you create a new slot with the same name as the old one. It does work if you cancel the swap before deleting the slot.
As long as it is in this state, a new swap (ApplySlotConfig) can't be ran.
If you cancel the swap in the Azure portal however, it works as expected and everything get's reset. Feels like the cmdlet should have the same effect.
Debug Output
When attempting to run ApplySlotConfig again you get the following error:
"Cannot apply configuration from slot 'Production' because this slot has already been prepared for swap with slot ''."
Script/Steps for Reproduction
Create a new slot
New-AzureRmWebAppSlot
Initiate a swap with preview
Switch-AzureRmWebAppSlot -SwapWithPreviewAction ApplySlotConfig
Delete the slot
Remove-AzureRmWebAppSlot
Attempt to reset the ongoing swap
Switch-AzureRmWebAppSlot -SwapWithPreviewAction ResetSlotConfig
Create a new slot
New-AzureRmWebAppSlot
Initiate a swap with preview again, and it throws
Switch-AzureRmWebAppSlot -SwapWithPreviewAction ApplySlotConfig
Activity