Search code examples
azureserviceazure-devopsproject

How to enable/disable project services through API


I am migrating from TFS 2015 to Azure DevOps. The process of creating the target project and importing the old git repository can easily be done through the Azure DevOps API.

But each new project, either created manually or by API has always all services (Boards, Pipelines, Test Lab, ...) enabled. Is there a way to change the default setting of which services should be enabled on new projects? Or even better an API method to switch certain services on / off?

We have hunderets of projects and therefor it's not feasible to open each project in the browser, change to the project settings page and adjust the services.

I haven't found anything in the docs: https://learn.microsoft.com/en-us/rest/api/azure/devops/?view=azure-devops-rest-5.0


Solution

  • This guy wrote a blog post on how to do this

    This is an excerpt pulled from his post:

    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  [Azure Pipelines]
    ms.vss-test-web.test [Test Plans]
    ms.vss-work.agile [Azure Boards]
    ms.vss-code.version-control [Azure Repos]
    ms.feed.feed [Azure Artifacts]
    

    It looks like turning a service off really just means hiding it from the UI.

    Edit: it looks like the .net SDK has built in support for this as well