Date posted: 31 May 2021, 1 minutes to read

Azure DevOps: enable project functionality

Sometimes you spot interesting things online that you have to figure out ๐Ÿ˜Ž. This time it was a tweet from Martin Ehrnst:

In Azure DevOps you can enable or disable features on a per-project basis:

Screenshot of Azure DevOps Settings Overview page on the project level

After some reverse engineering I found out that you can request and set the state of these features by calling into the API.

Getting the feature state

POST: https://dev.azure.com/{ORGANIZATION}/_apis/FeatureManagement/FeatureStatesQuery/host/project/{PROJECTID}?api-version=4.1-preview.1 Indicating in the body what you want to know. If you only pass in 1 featureId, you only get the state for that single feature.

{
    "featureIds": [
        "ms.vss-work.agile",
        "ms.vss-code.version-control",
        "ms.vss-build.pipelines",
        "ms.vss-test-web.test",
        "ms.feed.feed"
    ],
    "featureStates": {},
    "scopeValues": {
        "project": "{PROJECTID}"
    }
}

Setting the feature state

You can set the state of a feature by sending in a PATCH request for a single feature. Posting for multiple features in one go doesnโ€™t seem to work. This makes sense since the API also does it on a per feature basis. PATCH: https://dev.azure.com/{ORGANIZATON}/_apis/FeatureManagement/FeatureStates/host/project/{PROJECTID}/{featureId}?api-version=4.1-preview.1 With body:

{
    "featureId": "ms.feed.feed",
    "scope": {
        "userScoped": false,
        "settingScope": "project"
    },
    "state": 1
}

Where featureId from the body needs to match the featureId in the URL (find the list in the example above).

Observations

To bad you cannot pass in these settings through the API when you create a project. At least there is another way to get things working ๐Ÿ˜„.