Azure DevOps – Tips and Tricks – 18 – Get Azure DevOps Git Repository Permissions

In this article, we are going to learn how to retrieve the permissions assigned to Azure DevOps – Git Repository using Azure DevOps Rest API

Advertisements

Prerequisites

We are going to use the below tools in order to get the details about Users and the Groups which have access to the Azure DevOps Repository.

  • Azure DevOps Organization & Project
  • Postman

Introduction

It’s always a daunting job for Azure DevOps administrator to keep track of the access permissions on Azure DevOps resources (ex: Git Repos). In this article, we are going to learn how to get the repo about the Access Permissions for a given Azure DevOps Git repo using Azure DevOps Portal and Azure DevOps Rest API.

Advertisements

Azure DevOps Portal: Let’s look at the easiest option to download the report of all the permissions on a repo (or repos) given to individual users as well as Group. Navigate to Manage Repositories, select a repo and then click on the Security tab which displays all the Groups and Users to whom the permissions have been assigned to as shown below.

Azure DevOps - Tips and Tricks - 18 - Get Azure DevOps Git Repository Permissions - Repo Permissions
Azure DevOps – Tips and Tricks – 18 – Get Azure DevOps Git Repository Permissions – Repo Permissions

In the Security tab shown above, you can see Download detailed report button. Clicking on it will generate a report and Azure DevOps will send you an e-mail as shown below.

Azure DevOps - Tips and Tricks - 18 - Get Azure DevOps Git Repository Permissions - Repo Permissions - Email
Azure DevOps – Tips and Tricks – 18 – Get Azure DevOps Git Repository Permissions – Repo Permissions – Email

You can then use the Download Report link from the email to download the JSON file which contain the detailed data about the Permissions on the selected Repo.

Advertisements

Sometimes, you may want to perform some operations dynamically using some programs. In that case, you may want to invoke Azure DevOps Rest API to download the permission data. Let’s now understand how to invoke the APIs.

Azure DevOps Rest API:

Azure DevOps provides two APIs

  1. Returns the List of ALL Permission Reports that user has generated
  2. Returns ALL the permissions for a given Report

In order to consume the API’s you first need to generate the Azure DevOps PAT (Personal Access Token) and once it is ready, open the Postman and let’s make a Get call to the permissionsreport report to view the list of all the Reports that user has generated as shown below.

Azure DevOps - Tips and Tricks - 18 - Get Azure DevOps Git Repository Permissions - Repo Permissions - API Get
Azure DevOps – Tips and Tricks – 18 – Get Azure DevOps Git Repository Permissions – Repo Permissions – API Get

Once you provide all the details and click on the Send button to get the list of ALL the reports that user has generated as shown below.

Azure DevOps - Tips and Tricks - 18 - Get Azure DevOps Git Repository Permissions - Repo Permissions - All Reports
Azure DevOps – Tips and Tricks – 18 – Get Azure DevOps Git Repository Permissions – Repo Permissions – All Reports

Now, grab the id of the report from the above output which will be used in the next call.

Advertisements

Let’s now make another new call to the Permission Download Report by passing the id of the report to the permissionsreport/{id}/download endpoint as shown below.

Azure DevOps - Tips and Tricks - 18 - Get Azure DevOps Git Repository Permissions - Repo Permissions - All Reports - Download
Azure DevOps – Tips and Tricks – 18 – Get Azure DevOps Git Repository Permissions – Repo Permissions – All Reports – Download

Once all the details are provided, click on the send button which returns the entire JSON of all the permisions as shown below.

Azure DevOps - Tips and Tricks - 18 - Get Azure DevOps Git Repository Permissions - Repo Permissions - All Reports - Download Resp
Azure DevOps – Tips and Tricks – 18 – Get Azure DevOps Git Repository Permissions – Repo Permissions – All Reports – Download Resp

Summary

In this article, we have learnt how to get the list of all the permissions for a given repo(s) of any Azure DevOps project using the Azure DevOps Portal as well as the Azure DevOps Rest API.

Do you like this article? If you want to get more updates about these kind of articles, you can join my Learning Groups

WhatsApp

Telegram

Advertisements
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s