Whether you’re a developer, a project manager, or an IT professional, this guide is just for you. We’ll explore several methods, discuss their pros and cons, and ensure you walk away with a robust understanding of how to get Azure devops project id.
Table of Contents
How to get Project ID in Azure DevOps
Method 1: Using the Azure DevOps REST API – For the Power User
For those who frequently work with automation, scripting, or custom integrations, using the Azure DevOps REST API to fetch the Project ID is an incredibly powerful and efficient method. This is where you truly harness the programmatic capabilities of Azure DevOps.
To use the API, you’ll need a Personal Access Token (PAT) with sufficient permissions (at least “Project and Team (Read)” scope) or an OAuth 2.0 authorization flow. For simplicity, this tutorial focuses on using a PAT.
Prerequisites:
- Personal Access Token (PAT): Create a PAT in Azure DevOps (User settings -> Personal access tokens). Ensure it has the “Project and Team (Read)” scope.
- HTTP Client: Tools like Postman, Insomnia,
curl, or even a simple script usingInvoke-RestMethod(PowerShell) orrequests(Python) can be used.
API Endpoint:
The core API endpoint to list projects within an organization is:
GET https://dev.azure.com/{organization}/_apis/projects?api-version=7.1-preview.4
Example
https://dev.azure.com/fewlines4biju/_apis/projects/TeamTsinfo?api-version=7.1Copy and paste this url in your browser. See the screenshot below, we got the expected output, and the project ID is highlighted in red.

Step-by-step with curl (command-line tool):
- Obtain your PAT: Let’s say your PAT is
your_personal_access_token. - Construct the
curlcommand:Bashcurl -u :{your_personal_access_token} \ https://dev.azure.com/{your_organization_name}/_apis/projects?api-version=7.1-preview.4 \ -H "Accept: application/json"- Replace
{your_personal_access_token}with your actual PAT. - Replace
{your_organization_name}with your Azure DevOps organization’s name (e.g.,TechSolutionsUSA). - The
-uflag with:{PAT}tellscurlto use the PAT for basic authentication without a username (the colon before the PAT is crucial).
- Replace
- Execute the command: Run this command in your terminal.
- Parse the JSON Response: The API will return a JSON array of all projects within your organization. Each project object will contain its name, description, and, crucially, its
id(which is the Project ID GUID). - Example JSON Snippet (simplified):JSON
{ "count": 2, "value": [ { "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "name": "NorthwindTraders", "description": "E-commerce solutions for a global market", "url": "https://dev.azure.com/TechSolutionsUSA/_apis/projects/a1b2c3d4-e5f6-7890-1234-567890abcdef", "state": "wellFormed", "revision": 123 }, { "id": "f0e9d8c7-b6a5-4321-fedc-ba9876543210", "name": "ProjectPhoenix", "description": "Next-gen internal tools development", "url": "https://dev.azure.com/TechSolutionsUSA/_apis/projects/f0e9d8c7-b6a5-4321-fedc-ba9876543210", "state": "wellFormed", "revision": 456 } ] }From this response, you can easily identify theidfield corresponding to your project’sname.
Pros:
- Automation-Friendly: Ideal for scripts, CI/CD pipelines, and integrating with other systems.
- Programmatic Access: Allows for dynamic retrieval of Project IDs without manual intervention.
- Comprehensive: Can retrieve details for all projects in an organization.
Cons:
- Requires Setup: Needs a PAT and familiarity with API calls or scripting.
- Learning Curve: Steeper learning curve for beginners compared to UI methods.
- Security Consideration: Managing PATs requires careful attention to security.
Method 2: Azure DevOps CLI
For those who love working in the terminal and managing Azure resources via the command line, the Azure DevOps CLI extension is a powerful tool. It provides a consistent and efficient way to interact with your Azure DevOps organizations and projects.
Prerequisites:
- Azure CLI Installed: You need the Azure Command-Line Interface installed on your machine.
- Azure DevOps Extension: Install the Azure DevOps extension for the Azure CLI. If you haven’t already, run:
az extension add --name azure-devops - Logged In: Ensure you are logged into Azure CLI with an account that has access to your Azure DevOps organization.
az login - Set Default Organization (Optional but Recommended): To simplify commands, set your default Azure DevOps organization:
az devops configure --defaults organization=https://dev.azure.com/{your_organization_name}
Step-by-step to get Project ID:
List all Projects under a specific Organization
az devops project list --org https://dev.azure.com/YourOrgName --output tableExample
az devops project list --org https://dev.azure.com/fewlines4biju --output tableAfter executing the above query, I got the expected output as shown in the screenshot below

Filtering for a specific project:
You can also filter the output using JMESPath queries directly within the CLI to get just the ID for a known project name:
az devops project show --project "TeamTsinfo" --org https://dev.azure.com/fewlines4biju --query idAfter executing the above query, I got the expected output as shown in screenshot below

- List Projects: Use the
az devops project listcommand to get a list of all projects in your configured organization.Bashaz devops project list --output json- The
--output jsonflag will give you a JSON output, which is easy to parse. You can also use--output tablefor a more human-readable format, but it might not show the GUID explicitly.
- The
- Identify the Project ID: In the JSON output, each project will have an
idfield. Locate the project you’re interested in by itsnameand then copy its correspondingid. - Example Output Snippet (simplified):JSON
[ { "abfUri": "vstfs:///Classification/TeamProject/a1b2c3d4-e5f6-7890-1234-567890abcdef", "description": "E-commerce solutions for a global market", "id": "a1b2c3d4-e5f6-7890-1234-567890abcdef", "lastUpdateTime": "2023-10-26T10:00:00.000Z", "name": "NorthwindTraders", "properties": [ // ... other properties ], "revision": 123, "state": "wellFormed", "url": "https://dev.azure.com/TechSolutionsUSA/_apis/projects/a1b2c3d4-e5f6-7890-1234-567890abcdef", "visibility": "private" }, { "id": "f0e9d8c7-b6a5-4321-fedc-ba9876543210", "name": "ProjectPhoenix", // ... } ]As you can see, theidfield directly provides the Project ID.
Pros:
- Command-Line Efficiency: Great for terminal users and scripting.
- Consistent Interface: Part of the broader Azure CLI ecosystem.
- Powerful Filtering: JMESPath queries allow for precise data extraction.
Cons:
- Requires Installation: Azure CLI and the DevOps extension must be installed.
- Authentication: Requires logging in to Azure CLI.
- Learning Curve: Less intuitive for those unfamiliar with command-line tools.
Method 3: Using PowerShell
We can use the PowerShell script below to retrieve the project ID for your Azure DevOps project.
# Define variables
$orgName = "fewlines4biju"
$projectName = "TeamTsinfo"
$pat = "9llg5jenochbEGi4NkfiYaUcYMbYnzcyLoqbNMvwVRMxtlkUQY04JQQJ99CAACAAAAAAAAAAAAASAZDO2aIU"
# Create Authorization Header
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$pat"))
$headers = @{Authorization = "Basic $base64AuthInfo"}
# API URL to get project details
$url = "https://dev.azure.com/$orgName/_apis/projects/$($projectName)?api-version=7.1"
try {
$response = Invoke-RestMethod -Uri $url -Method Get -Headers $headers
$projectId = $response.id
Write-Host "The Project ID for '$projectName' is: $projectId" -ForegroundColor Cyan
}
catch {
Write-Error "Failed to retrieve project. Check your Project Name, Org, or PAT."
}After executing the above script, I got the expected output as shown in the screenshot below.

Best Practices for Handling Project IDs
Now that you know how to find your Project ID, let’s touch on a few best practices to ensure you’re using this information effectively and securely:
- Don’t Hardcode in Production: While it’s okay for quick tests, avoid hardcoding Project IDs directly into production scripts or applications. Instead, use environment variables, configuration files, or better yet, retrieve them dynamically using the API or CLI based on the project name. This makes your solutions more flexible and easier to maintain.
- Manage PATs Securely: If you’re using PATs for API or CLI access, treat them like passwords. Store them securely, rotate them regularly, and grant them only the minimum necessary permissions (e.g., “Project and Team (Read)” for just getting the ID).
- Document Your Projects: Especially in larger organizations with many projects (I’m looking at you, enterprise teams across the US!), maintain a document or wiki that lists project names alongside their IDs. This serves as a quick reference for your team.
- Understand the Difference: Name vs. ID: Always remember that a Project Name is human-readable and can sometimes change (though it’s rare and discouraged once a project is mature). The Project ID (GUID) is the immutable, unique identifier that Azure DevOps uses internally. When building automated solutions, always prioritize using the ID.
Video Tutorial
Conclusion:
Getting your Azure DevOps Project ID is a fundamental skill that every Azure DevOps developer needs to know. Mastering these methods will make your workflow smoother and more powerful.
You may also like the following articles:
- How To Write Queries In Azure Devops
- How to add team members in Azure DevOps
- How to Abandon PR in Azure DevOps
- How To Recover Deleted Branch In Azure DevOps
- Azure DevOps What Is It

I am Rajkishore, and I am a Microsoft Certified IT Consultant. I have over 14 years of experience in Microsoft Azure and AWS, with good experience in Azure Functions, Storage, Virtual Machines, Logic Apps, PowerShell Commands, CLI Commands, Machine Learning, AI, Azure Cognitive Services, DevOps, etc. Not only that, I do have good real-time experience in designing and developing cloud-native data integrations on Azure or AWS, etc. I hope you will learn from these practical Azure tutorials. Read more.
