How to find disabled azure services in azure devops project - azure-devops

We can disable azure devops services form UI
Is there any API available to GET the info about enabled / disabled services ?
Like in above image boards is disabled , Can I find this info using API ?

This is an feature in Project Settings.
I checked the related REST API and Azure CLI for Team Projects, however I did not find any available interface can list the info about enabled / disabled services, also no available interface to enabled / disabled services.
So, I think your question is more like a feature request. I recommend that you can report the feature request to Developer Community.
[UPDATE]
I found below API from the Network logs of the web browser (press F12). I have tested this API on my side, it should be the one you are looking for.
Request URI:
POST https://dev.azure.com/{Organization_name}/_apis/FeatureManagement/FeatureStatesQuery/host/project/{Project_id}?api-version=4.1-preview.1
Request Body:
{
"featureIds": [
"ms.vss-work.agile", // Boards
"ms.vss-code.version-control", // Repos
"ms.vss-build.pipelines", // Pipelines
"ms.vss-test-web.test", // Test Plans
"ms.feed.feed" // Artifacts
],
"featureStates": {},
"scopeValues": {
"project": "{Project_id}"
}
}
Response Body:
{
"featureIds": [
"ms.vss-work.agile",
"ms.vss-code.version-control",
"ms.vss-build.pipelines",
"ms.vss-test-web.test",
"ms.feed.feed"
],
"featureStates": {
"ms.vss-work.agile": {
"featureId": "ms.vss-work.agile",
"scope": {
"userScoped": false,
"settingScope": "project"
},
"state": "disabled"
},
"ms.vss-code.version-control": {
"featureId": "ms.vss-code.version-control",
"scope": null,
"state": "enabled"
},
"ms.vss-build.pipelines": {
"featureId": "ms.vss-build.pipelines",
"scope": null,
"state": "enabled"
},
"ms.vss-test-web.test": {
"featureId": "ms.vss-test-web.test",
"scope": null,
"state": "disabled",
"reason": "\"Test Plans\" is off because the \"Boards\" feature is off. In order to manage \"Test Plans\", you must turn on \"Boards\".",
"overridden": true
},
"ms.feed.feed": {
"featureId": "ms.feed.feed",
"scope": null,
"state": "enabled"
}
},
"scopeValues": {
"project": "{Project_id}"
}
}

The right name of the features are:
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.azure-artifacts.feature [Azure Artifacts]

Related

Add Reporsitory to GitHub Connection in ADS

How to add GitHub repository to ADS (On-Prem) connection using API. Followed this link to establish connection between GitHub repos and ADS (GitHub connection). We can add repos manually, we are looking for APIs to add the repos.
Is there any API using which we can add GitHub repos to the GitHub connections in ADS?
There isn't a documented REST API that can do this. But when I checked the Developer Console, I found that there is indeed a REST API that can add repository with existing GitHub connection:
POST https://dev.azure.com/{organization}/_apis/Contribution/HierarchyQuery?api-version=5.0-preview.1
Here is a sample request body:
{
"contributionIds": [
"ms.vss-work-web.github-unified-installation-experience-data-provider"
],
"dataProviderContext": {
"properties": {
"orgName": "{organization}",
"externalRepositoryExternalIds": [
"{RepositoryExternalIds}",
"{RepositoryExternalIds}"
],
"existingConnectionId": "{ConnectionId}",
"sourcePage": {
"url": "https://dev.azure.com/{organization}/{project}/_settings/boards-external-integration",
"routeId": "ms.vss-admin-web.project-admin-hub-route",
"routeValues": {
"project": "{project}",
"adminPivot": "boards-external-integration",
"controller": "ContributedPage",
"action": "Execute"
}
}
}
}
}
In the externalRepositoryExternalIds section, note that you need to include all the repository ids you want, not just the new ones you want to add.
Other information that might help: If you change the request body, the REST API will return all repositories that are currently connected. Here are some examples:
{
"contributionIds": [
"ms.vss-work-web.azure-boards-external-connection-data-provider"
],
"dataProviderContext": {
"properties": {
"includeInvalidConnections": true,
"sourcePage": {
"url": "https://dev.azure.com/{organization}/{project}/_settings/boards-external-integration",
"routeId": "ms.vss-admin-web.project-admin-hub-route",
"routeValues": {
"project": "{project}",
"adminPivot": "boards-external-integration",
"controller": "ContributedPage",
"action": "Execute",
}
}
}
}
}

How to get the list of published artifacts from an Azure DevOps build

Azure DevOps provides a view of published artifacts after a build has completed, my question is, is there an API endpoint that lists these artifacts?
This API is not officially documented, but you can get it from the developers tools in the Artifacts page.
So, the API url is:
https://dev.azure.com/{org-id}/_apis/Contribution/HierarchyQuery/project/{project-id}
And the body should be:
{
"contributionIds": [
"ms.vss-build-web.run-artifacts-data-provider"
],
"dataProviderContext": {
"properties": {
"artifactId": {artifact-id},
"buildId": {build-id},
"sourcePage": {
"url": "https://dev.azure.com/{org-id}/{project-id}/_build/results?buildId=1210\u0026view=artifacts\u0026pathAsName=false\u0026type=publishedArtifacts",
"routeId": "ms.vss-build-web.ci-results-hub-route",
"routeValues": {
"project": "{project-id}",
"viewname": "build-results",
"controller": "ContributedPage",
"action": "Execute",
"serviceHost": "{host-id} ({username})"
}
}
}
}
}
In the response you will get items section with the file names.
You can in the first to go the build artifacts page, press on F12 and see the values for the {} in the body I provided.

Azure DevOps OAuth organization policies API

is there a way to know via API what is the organization policy for 3rd party OAuth requests?
i want to know if i should ask my user to authenticate with his credentials or generate PAT
is there a way to know via API what is the organization policy for 3rd
party OAuth requests?
You can use this api which I fetched from F12:
Get https://dev.azure.com/{YourOrgName}/_settings/organizationPolicy?__rt=fps&__ver=2
The response would contain the info about Application Connection Policies:
"ms.vss-admin-web.organization-policies-data-provider": {
"policies": {
"applicationConnection": [
{
"policy": {
"name": "Policy.DisallowOAuthAuthentication",
"value": false,
"effectiveValue": true,
"parentPolicy": {
"name": "Policy.DisallowOAuthAuthentication",
"value": false,
"effectiveValue": true,
"isValueUndefined": true
}
},
"learnMoreLink": "https://aka.ms/vstspolicyoauth",
"description": "Third-party application access via OAuth",
"applicableServiceHost": 1
},
{
"policy": {
"name": "Policy.DisallowSecureShell",
"value": false,
"effectiveValue": true,
"isValueUndefined": true,
"parentPolicy": {
"name": "Policy.DisallowSecureShell",
"value": false,
"effectiveValue": true,
"isValueUndefined": true
}
},
"learnMoreLink": "https://aka.ms/vstspolicyssh",
"description": "SSH authentication",
"applicableServiceHost": 1
}
]...
The effectiveValue(not value node) node under corresponding policy node should represent whether you enable/disable the policies above in your pic. E.g: The effectiveValue node under first policy node would be false if the Third-party application access via OAuth is disabled.

Add/remove pipeline checks using REST API

I have a requirement to dynamically add/remove or enable disable approval and checks at azure DevOps pipeline environment.
Is there a rest api for this?
Is there a rest api for this?
Yes, it has. BUT, as what the #Krysztof said, we haven't provide such api documents to public as of today. This is because what you are looking for is one feature (configure Check and approval from environments ) that only support for YAML pipeline, and until now, we are developing but does not publish the corresponding rest api (for YAML) docs.
But, as work around, you can catch these apis from F12. Just do action from UI, then capture and analyze corresponds api records to found out what you are expecting.
Here I make the summary to you.
The api that used to add/delete approval and check to environment is:
https://dev.azure.com/{org name}/{project name}/_apis/pipelines/checks/configurations
The corresponding api method for add or delete is Post and DELETE.
Firstly, share you the request body samples which for approval and check added.
1) Add approval to this environment:
{
"type": {
"id": "8C6F20A7-A545-4486-9777-F762FAFE0D4D", // The fixed value for Approval
"name": "Approval"
},
"settings": {
"approvers": [
{
"id": "f3c88b9a-b49f-4126-a4fe-3c99ecbf6303" // User Id
}
],
"executionOrder": 1,
"instructions": "",
"blockedApprovers": [],
"minRequiredApprovers": 0,
"requesterCannotBeApprover": false // The pipeline requester allow to approve it.
},
"resource": {
"type": "environment",
"id": "1", // Environment id
"name": "Deployment" //Environment name
},
"timeout": 43200 // Set the available time(30d) of this approval pending. The measure unit is seconds.
}
2) Add task check, Azure function, Invoke rest api task and etc:
{
"type": {
"id": "fe1de3ee-a436-41b4-bb20-f6eb4cb879a7", // Fixed value if you want to add task check
"name": "Task Check" //Fixed value
},
"settings": {
"definitionRef": {
"id": "537fdb7a-a601-4537-aa70-92645a2b5ce4", //task Id
"name": "AzureFunction", //task name
"version": "1.0.10" //task version
},
"displayName": "Invoke Azure Function", //task display name configured
"inputs": {
"method": "POST",
"waitForCompletion": "false",
"function": "csdgsdgsa",
"key": "436467543756" // These are all task inputs
},
"retryInterval": 5, // The re-try time specified.
"linkedVariableGroup": "AzKeyGroup"// The variable group name this task linked with
},
"resource": {
"type": "environment",
"id": "2",
"name": "Development"
},
"timeout": 43200
}
In this request body, you can find the corresponding task id from our public source code. Just check the task.json file of corresponding task.
3) Add template check:
{
"type": {
"id": "4020E66E-B0F3-47E1-BC88-48F3CC59B5F3", // Fixed value for template check added.
"name": "ExtendsCheck" //Fixed value
},
"settings": {
"extendsChecks": [
{
"repositoryType": "git", // github for Github source, bitbucket for Bitbucket source
"repositoryName": "MonnoPro",
"repositoryRef": "refs/heads/master",
"templatePath": "tem.yml"
}
]
},
"resource": {
"type": "environment",
"id": "6",
"name": "development"
}
}
In this body, if the template source is coming from github or bitbucket, the value of repositoryName should like {org name}/{repos name}.
Hope these are helps.
This is an older question but we had a similar need. There does not appear to be a direct API To query this, but this GitHub Project pointed us in the right direction:
# GET ENVIRONMENT CHECKS (stored under .fps.dataProviders.data['ms.vss-pipelinechecks.checks-data-provider'].checkConfigurationDataList)
GET https://dev.azure.com/{{organization}}/{{project}}/_environments/{{environment_id}}/checks?__rt=fps&__ver=2
As mentioned above under .fps.dataProviders.data['ms.vss-pipelinechecks.checks-data-provider'].checkConfigurationDataList the list of who is authorized is provided.
The officially documented APIs can tell you that there are checks in place; for example:
GET https://dev.azure.com/{organization}/{project}/_apis/pipelines/checks/configurations?resourceType=environment&resourceId={id}
Can tell you that you have checks enabled (including an Approval check) but this isn't super useful as it does not give a list of who can Approve.
Note that you can get the list of environments (to get their resource ID) using this documented API:
GET https://dev.azure.com/{organization}/{project}/_apis/distributedtask/environments?api-version=7.1-preview.1
This is not supported at the moment. You can upvote feature request to show your interest here.

Add ARM Service Endpoint programatically in VSTS

I have an existing SPN in Azure AD and want to add to VSTS programatically.
Is this possible?
VSTS Rest-API? Examples?
Through powershell?
You can use the REST API to manage your endpoints.
For example the following POST will create an Azure endpoint:
https://fabrikam.visualstudio.com/DefaultAgileGitProject/_apis/serviceendpoint/endpoints?api-version=4.1-preview.1
{
"data": {
"SubscriptionId": "12345678-1234-1234-1234-123456129012",
"SubscriptionName": "TestSubscriptionName"
},
"id": "64be39c2-102b-416d-a3ac-2de40ebc8513",
"name": "TestEndpoint",
"type": "Azure",
"authorization": {
"parameters": {
"Certificate": "dummyCertificate"
},
"scheme": "Certificate"
},
"isReady": false
}
You can find the full documentation here: https://learn.microsoft.com/en-us/rest/api/vsts/serviceendpoint/endpoints/create?view=vsts-rest-4.1