VSTS Plugin for FeatureSwitcher

Today I released a Visual Studio Team Service (VSTS) Plugin for FeatureSwitcher – an open source .NET project to help you with FeatureFlags. The FeatureSwitcher.VstsConfiguration allows you to store and manage FeatureFlags as WorkItems in VSTS.

Getting started

The package is available via NuGet. Install it in your project.

Install-Package FeatureSwitcher.VstsConfiguration

Now add the using directives for FeatureSwitcher.VstsConfiguration and FeatureSwitcher.Configuration.

using FeatureSwitcher.VstsConfiguration;
using FeatureSwitcher.Configuration;

Configure FeatureSwitcher to use VSTSConfig. You have to specify the url to your VSTS project (https://youraccount.visualstudio.com/ProjectName) and a personal access tokens. This is enough if you want to use the default configuration.

.WithVSTSUrl(new Uri("http://youraccount.visualstudio.com/yourproject"))
.WithPrivateAccessToken("Your PAT token");

The code will create a WorkItem of the type task by default and add a tag “FeatureFlag”. The title of the task will contain the name of your feature (depending on your naming conventions). The value is stored in the description field. Change the value from “False” to “True” and save the WorkItem. Your feature flag is now turned on.



The solution supports the concept of environments. The environment is added as a separate tag to the WorkItem and allows multiple flags with the same name (normally it must be unique). Like this you can use the flag in Dev, Test, QA and Prod with different values.

.WithVSTSUrl(new Uri("http://youraccount.visualstudio.com/yourproject")
.WithPrivateAccessToken("Your PAT token")

Custom WorkItemTypes

You can customize how the FeatureFlags are stored in VSTS. You can specify your own WorkItemType, the fields and the query that is used to retrieve them.

For example: you can create a new WorkItemType called “FeatureFlag” and add fields to store the name and the value of the flag. You can add additional fields like priority and additional tags and expand the query to filter WorkItems based on these values.

This helps you organize your flags and allows multiple projects, environments, users etc. in one VSTS project.

var settings = new VstsSettings
    Url = new Uri("http://youraccount.visualstudio.com/yourproject"),
    PrivateAccessToken = "Your PAT token",
    WorkItemType = "FeatureFlag",
    NameField = "FeatureFlag.Name",
    ValueField = "FeatureFlag.Value",
    AdditionalQueryFilter = "and [System.Tags] Contains 'XYZ' and [Microsoft.VSTS.Common.Priority] = 1",
settings.AdditionalFields.Add("Microsoft.VSTS.Common.Priority", "1");
settings.AdditionalFields.Add("System.Tags", "XYZ");




So that’s it for the first introduction. Let me know what you think of the solution. I hope to use it in my next projects – so hopefully it will involve. It is complete open source – so you are welcome to contribute.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s