Checking the Status of an Azure Web App Swap using PowerShell

This past week I was working with a customer who wanted to check the status of a swap with an Azure Web App using TFS. One option would be to use the Swap deployment task and the other would be to query the status using PowerShell. In order to do so we query the Activity Log to get the status. The first line gets the format of the date in a format that the Azure SDK for PowerShell recognizes. The next line we get the current status.

The caller value is optional

We only need one record so we set the -MaxRecord to 1

The status we are looking for is Succeeded

We add the -ResourceId of the slot we are trying to swap

Finally we add the StartTime to be that of the current date

Next we loop through the wile statement until we finally get a result stating the swap succeeded and we exit the while loop.