If you use Azure Web App Deployment Slots then you may have noticed that sometimes the swap action may take a while to complete. This may happen when an application that is being swapped into production has a long warmup/initialization phase. It has to be warmed up on every VM in an App Service Plan and that sometimes takes minutes (more detailed description of what happens during the swap can be found in Most common deployment slot swap failures and how to fix them). This blog post explains how to see the progress and the result of the swap operation in the Azure Activity Log.
To see the swap operation events use the Activity log view in the Azure Portal:
Here is an example of how the swap events look like:
- ApplySlotConfig – this is logged when slot settings from production slot have been applied to a webapp in the staging slot
- StartSlotWarmup – this is logged when starting to initialize the webapp in the staging slot
- EndSlotWarmup – this indicates that the webapp initialization has completed
- SlotSwap – this is logged when the webapp from the staging slot has been swapped into production slot.
If there was a failure while swapping the slots then the events will look like below. The event description will have explanation of why the failure occurred.
If you use PowerShell then you can get the swap related events by using this command:
Get-AzureRmLog -ResourceGroup slotswaptest -StartTime 2018-03-07 -Caller SlotSwapJobProcessor
This will produce an output as below:
(For more information on how to get Activity Log events via Powershell refer to View activity logs to audit actions on resources)
If you prefer to call the Azure API’s directly (or by using ARMClient tool) then you make a request like below:
ArmClient.exe GET "//providers/microsoft.insights/eventtypes/management/values?api-version=2015-04-01&$filter=eventTimestamp ge '2018-03-07T00:00:00Z' and eventTimestamp le '2018-03-08T23:00:00Z' and resourceGroupName eq 'slotswaptest'"
In the response look for events that have Caller property set to “SlotSwapJobProcessor“.