Using Azure Activity Log to check the progress of deployment slots swap operation

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:

Activity Log

Here is an example of how the swap events look like:

Swap events example
  1. ApplySlotConfig – this is logged when slot settings from production slot have been applied to a webapp in the staging slot
  2. StartSlotWarmup – this is logged when starting to initialize the webapp in the staging slot
  3. EndSlotWarmup – this indicates that the webapp initialization has completed
  4. 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.

Failed swap event in activity log

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:

Activity Log in PowerShell

(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“.

6 thoughts on “Using Azure Activity Log to check the progress of deployment slots swap operation”

  1. Not seeing these Activity Log items for slot swaps any more. All we see are “Microsoft.Web/sites/slots/write”

  2. Thanks. Wondering if it fixes the monitoring the swap operation using the technique here https://github.com/projectkudu/AzureResourceExplorer/issues/52 – we get the OperationId back from MSDeploy (“Info: Finished publishing with auto-swap enabled: SlotName=production, OperationId=ca4e59c0…”) and use this to ping “/operations/{OperationId}” and get 202 Accepted until the swap is complete and we get 200 OK. This stopped working around the same time (sometimes it works, mostly doesn’t).

Leave a Reply

Your email address will not be published. Required fields are marked *