Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add Azure AD user to Azure DevOps organisation programmatically

My organisation is connected to Azure AD.

I'd like to add AD users to my Azure DevOps organisation with C# or via Microsoft REST/Graph API.

Adding user to organisation

like image 479
pizycki Avatar asked Oct 15 '22 09:10

pizycki


1 Answers

You can do it with User Entitlements - Add Rest API:

POST https://vsaex.dev.azure.com/{organization}/_apis/userentitlements?api-version=5.1-preview.2

Example of the json body:

{
  "accessLevel": {
    "accountLicenseType": "express"
  },
  "extensions": [
    {
      "id": "ms.feed"
    }
  ],
  "user": {
    "principalName": "[email protected]",
    "subjectKind": "user"
  },
  "projectEntitlements": [
    {
      "group": {
        "groupType": "projectContributor"
      },
      "projectRef": {
        "id": "e5943a98-a842-4001-bd3b-06e756a7dfac"
      }
    }
  ]
}
like image 145
Shayki Abramczyk Avatar answered Oct 31 '22 22:10

Shayki Abramczyk