Skip to content

Re-usable Azure Function for Azure DevOps Deployment gates.

Notifications You must be signed in to change notification settings

ricmrodrigues/DeploymentGates

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Azure DevOps Time based deployment gates

Motivation

In our engineering system we often have CI/CD pipelines in Azure DevOps and frequently use the “Auto-Complete” feature on our pull requests. These two features combine might result in a deployment when no one around which we generally try to avoid.

Azure DevOps allows you to Control Deployments using gates.

See: https://docs.microsoft.com/en-us/azure/devops/pipelines/release/approvals/gates?view=azure-devops

High Level Design.

Create a re-usable azure function which can be shared with multiple pipelines. Each pipeline owner can pass settings to the function about when the team believes is a safe time to deploy.

All of the settings are configured at the pipeline level. This allows you to deploy the Azure Function once and have multiple pipelines target it and share the resource.

Examples of gates this project enables:

Example 1. Only deploy on Monday thru Friday

POST:

{  
  "timeZoneId": "Eastern Standard Time",  
  "validDaysOfWeek": [ 'Monday', 'Tuesday', 'Wednesday','Thursday','Friday' ]
}

Example 2: Only deploy during business hours

POST:
{
  "startTimeSpan": "9:00",
  "endTimeSpan": "17:00",
  "timeZoneId": "Eastern Standard Time"
}

Example 3: Do not deploy on Company Holidays Or other days of the year.

POST
{
  "timeZoneId": "Eastern Standard Time",
  "invalidDates": ['1/1/2019', '12/24/2019',  '12/25/2019', '9/2/2019', '11/28/2019', '11/29/2019']
}

Example 4: All of the above in a single Deployment Gate

POST
{
  "timeZoneId": "Eastern Standard Time",
   "validDaysOfWeek": [ 'Monday', 'Tuesday', 'Wednesday','Thursday','Friday' ],
  "startTimeSpan": "9:00",
  "endTimeSpan": "17:00",
  "invalidDates": ['1/1/2019', '12/24/2019',  '12/25/2019', '9/2/2019', '11/28/2019', '11/29/2019']
}

Part 1: The Azure Function

Build and deploy the Publish the DeploymentGate project to your Azure subscription.

Part 2: Edit your Release Pipeline

Add Deployment Gate

Enter the Function url and the function Key

In the body field: Pass your configuration settings

{
  "timeZoneId": "Eastern Standard Time",
   "validDaysOfWeek": [ 'Monday', 'Tuesday', 'Wednesday','Thursday','Friday' ],
  "startTimeSpan": "9:00",
  "endTimeSpan": "5:00",

  "invalidDates": ['1/1/2019', '12/25/2019']
}

or use one of the other examples above. SuccessCriteria

Under Advanced. Be sure to put. eq(root. SuccessCriteria, true)

Save and test your pipeline.

About

Re-usable Azure Function for Azure DevOps Deployment gates.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%