VSTS: Disable features/services API

VSTS is rolling out a new navigation. One of the features in it is the ability to turn off certain services/features, such as Test, Build and Release, etc. But you have to go into each project individually. That’s manual work, I want to automate it.

So if you want to disable some services/features in VSTS across multiple projects there is a REST API that you can use. It’s in preview, and you’ll have to script the calls but here you go:

1
2
3
4
PATCH https://{account}.visualstudio.com/_apis/FeatureManagement/FeatureStates/host/project/{project-id}/{feature-id}?api-version='4.1-preview.1'
content-type: application/json

{"featureId":"{feature-id}","scope":{"settingScope":"project","userScoped":false},"state":0}

Replace account,project-id and feature-id as appropriate. Here are the feature id’s I know of.

  • ms.vss-build.pipelines
  • ms.vss-test-web.test
  • ms.vss-work.agile
  • ms.vss-code.version-control

Using the VSTeam PowerShell module

1
2
3
4
5
6
7
8
# Get the build feature setting
$buildFeature = Invoke-VSTeamRequest -Area FeatureManagement -Resource FeatureStates -Id "host/project/$($project.Id)/ms.vss-build.pipelines"

# Adjust the setting: 0 | 1 | 'undefined'
$buildFeature.state = 0

# Update VSTS
Invoke-VSTeamRequest -method patch -ContentType 'application/json' -body ($buildFeature | ConvertTo-Json -Depth 5 -Compress) -Area FeatureManagement -Resource FeatureStates -Id "host/project/$($project.Id)/ms.vss-build.pipelines" -version '4.1-preview.1' | Out-Null

Host level settings

You can also do the above at the ‘host’ level. From my experimentation that’s the project collection as a whole.

1
https://{account}.visualstudio.com/_apis/FeatureManagement/FeatureStates/host/{feature-id}

Same payload, in that case you are simply ignoring the project. However, this doesn’t actually remove the service/feature from all the projects. What it does is removes them from the services page. You won’t even see a ‘Build and Release’ toggle for example. So be careful, if you disable a service at the host level but it’s enabled at the project level (or undefined) then the project can still use that service as usual, but you won’t be able to turn it on/off via the new navigation ui.

Developing behind a proxy

Working behind a proxy can be annoying at times but it’s not difficult to work with, most of the time that is. This is mostly here for my own reference in the future and you get the added benefit.

OctoPygmy

I am a great fan of Octopus Deploy. In the interest of improving it in any way I can I released a beta version of OctoPygmy, a Chrome extension for Octopus Deploy.

The case for abstract IoC

I really value the IoC libraries out there and the features each one provides. I use one in nearly all the applications I write. Along with IoC libraries there has been the occasional discussion on abstracting it away from the application. I’m not a fan of this idea.