Flow of the Week: Tracking Deployments

Hello Flow Community!

Today were bringing you a post from one of our internal Engineers. This post is about a Flow that we, the team use in our own environment and work day.

The Microsoft Flow portal and the backend service are deployed to multiple Azure regions. New features and bug fixes are deployed by the team at a regular cadence. The deployment is done through a safe deployment sequence – an approach wherein deployment proceeds from regions with least usage to regions with highest usage. During a deployment, the team may get an incident through automated runners or through a customer report. At this point, the team must investigate the incident and make several decisions. This involves:

  • Investigating the impact of the incident
  • Determining the cause of the incident
  • Determining which regions are impacted by the incident
  • Deciding whether to halt the current deployment sequence and roll back to previous stable bits
  • Deciding whether to roll out a hotfix

The time required to investigate and take corrective actions can be significantly reduced if we have all relevant information easily accessible.

 

Solution

We solve part of the problem by tracking current and historical information about deployments through Microsoft Flow. We do this by maintaining the current deployment snapshot and the log of previous deployments in two SharePoint lists. In this blog, we will walk through the flow that helps capture these data points for reference during investigations.

image

 

Getting the version of current deployed bits

Microsoft Flow portal and the backend service log information that helps monitor the health of the service. These logs move through a data pipeline and finally land in Kusto, an internal data warehouse. We have a custom connector for Kusto which allows us to query data in Kusto through a flow.
 
We can get the version of the current deployed bits for both the portal and backend service by making a query to Kusto. Further, since a deployment can complete anytime, we run the query every 5 minutes. Even though we run the flow at a 5 minutes frequency, we look at the last 1 hour of data to get the list of recent deployments. This is done to factor in any latency in copying logs from the deployed service to Kusto, clock skews and even transient failures in downstream systems.

Processing the list of recent deployments

Once we get the list of recent deployments from Kusto, we need to iterate over each deployment record to process them – so, we add an “Apply to each” block. Since the flow runs at a frequency of 5 minutes but looks back at 1 hour of data, it is possible that some of the deployment information has already been processed. To handle this case, we check if for a record a corresponding item has been created in the “Deployments history” list. Since we know the exact record that we are looking for, we can construct an ODATA filter query to get an exact match of this record – if it is in the list.
 
We determine whether a corresponding item is in the Deployment history list by checking the length of the item list returned by the above action. If the length is 0 – which means no corresponding item was found in the Deployment History list – we then try to find the corresponding item in the Current Snapshot list. This is again done by using an ODATA filter to find an exact match. Since the Current Snapshot list was initially created to have one item per Environment, Role, and Region, we will always find one unique record.

 

Create new deployment history item and update current snapshot

Since the filter on Current Deployment snapshot list returns a list of matches – even though it will always return a single item – we need to extract the first object of the list. We do this by using a Compose action followed by a ParseJson action. The output of ParseJson action can be used in subsequent actions.
 
Finally, we create a new item in the Deployment History list and update the Current Deployment
 

 

Summary

Using Microsoft Flow it was super easy to build a no code solution to both track deployment history and track the state of current deployments across regions.