You shall not push - branch policies in VSTS

When working on a codebase with a team, you always want to make sure, that everything is kept clean and works smoothly. You have git-flow, you have code reviews - they ensure, that everyone can work without impacting others and the main branch is secured. There's one issue however - by default you cannot force team members to go through the whole process - creating a feature branch, pull request, code review. Fortunately VSTS allows you to set a branch policy, which will ensure, that no one breaks the rules.

Setting a branch policy

TO set-up a branch policy just go to Code->Branches page. Choose whichever branch you want and select Branch policies item.

You'll see a page, where you can choose to protect this particular branch. When you select the checkbox, you'll see different options to make sure it is secured. We'll go through each one to get a basic understanding what it gives us.

Minimum number of reviewers

It allows us to define what is the minimum number of reviewers to actually complete a pull request. What is important here is Allow users to approve their own changes checkbox - if you want to force, that someone has reviewed a PR, make sure it is not checked!

Check for linked items

Useful when working with VSTS issue tracker. Allows you to block a PR if a work item hasn't been linked to it.

Check for comment resolution

My favorite. Forces an author of a PR to make sure, that each comment has been reviewed and accepted. 

Build validation

Allows you to link a build definition to queue a build for a PR to make sure, that feature branch passes through the whole pipeline. No more broken builds!

Results

When a branch policy is set, let's try to do following thing - push a commit directly to a develop branch(or any other branch which is protected) and complete a pull request.

Pushing a commit directly to the protected branch will result in an error

In this case both build and approvals weren't finished

Summary

As you can see in VSTS you can easily set a branch policies, which will help you secure your main branch from broken features. What is more, they will ensure you, that each team member follows the same process and no change can affect other team members.

 

 

Real cost of developing a project in Azure

Recently I've moved one of my side projects fully to the cloud. In this short post I'd like to show you what is the real cost of developing a fairly small yet multi-dimensional project and how Azure gives me and my client flexibility to select what is really needed in this particular moment.

The project

I won't go into details here. Just to make a long story short - we're gathering data from many electronic devices and then provide reports based on different time intervals, places and custom properties to the clients. There's also a need to handle the old legacy system and migrate data from the old database to the new one.

Azure components

Mentioned project is built using following elements:

  • Storage account
  • Function App
  • 2x Web App
  • SQL database
  • Azure B2C
  • Application Insights

worth mentioning here is the fact, that by default we're using free tiers for Web Apps and SQL server.

Taking into consideration all above our monthly cost of developing this project is 1,50 EUR on average.

Caveats

Because we're using free tiers, we have to be aware of limits - like available CPU minutes per day - but on the other hand, there's no problem to scale up when needed. This is what really made us into cloud - if only small features are being developed, free tier is more than enough. If we're during a strenuous period of developing new features, we can just go to the portal and change a tier.

Additionally we have to be aware, that on production we won't be able to use free versions of Azure components because of lacking features and much higher traffic. On the other hand, saving money in such way instead of paying much more money for resources we won't be able to utilize is a much smarter decision.

Detailed cost

There're two resources which make the most of our cost: Storage account and Function App. This is because they're the "hot path" in the system - one of the functions fetches data from FTP and pushes each record to a queues. Other functions take data from queues and perform some transformations, store data and push it further. When I checked my Billing page, the cost looks like this:

  • Storage account 0,62 EUR
  • Function App 0,55 EUR
  • B2C 0,09EUR
  • The rest of resources 0 EUR

We didn't need more power this month so we could keep the lowest cost possible.

Summary

Carefully designed cloud solution could really lower monthly cost of developing a project. On the other hand I've seen many examples, where developing a product in the cloud was much more expensive than an old-fashioned VM(or even a production environment also hosted somewhere in Azure!). Pay attention to resources used, selected tiers and their utilization and you won't be surprised when you see a bill at the end of a month.