Flow of the Week: Automated notification when a new build is deployed to Production
The Microsoft Flow development team internally uses a bunch of flows that save us many person-hours, and that are interesting to showcase real-world use cases.
For today, I'll talk about a flow that we use that we use to notify our team to test the new Microsoft Flow portal build (https://flow.microsoft.com) that is going to be rolled out to all our regions. Previously, this was a manual process – internally the development leads would need to remember that a build was in the pre-production slot and remind the team to validate the bits to catch any last minute regressions. Naturally, there were lots of misses due to the human intervention this requires.
We ended up creating a flow that does this quite trivially. The logic can be summed up as:
- Every hour
- Query the build that is in pre-production
- Compare the build version with the version that was previously in pre-production
- If they are different, then send an email to test and update state to mark deployed build as current for next check.
A couple of interesting things to note:
- The previous build state is stored as a JSON file in a SharePoint site
- The Parse JSON method is used to extensively parse and extract JSON tokens
Querying the bits in pre-production is accomplished using the HTTP GET action against our endpoint (https://flow.microsoft.com/healthcheck – you can execute the same action against our endpoint, it is un-authenticated). The response is standard JSON and it contains the build version in the "x-ms-request-id" value. The results from an executed flow run (with highlighted the build version) are here:
I use the ParseJSON action to parse the headers. The Use sample payload to generate schema is pretty handy if you don't want to deal with schema definition (this is the easiest way I found to generate a JSON schema).
I use a file stored on a SharePoint site as a "state" to store the last deployed build. The file is a simple JSON with the value of the last build number as shown below. I had to create the file manually the first run to be ready.
I hope this was useful for you. As always you can ask questions here or on the flow discussion forums.