Azure Devops Visual Studio Code



  1. Azure Devops Visual Studio Code Integration
  2. Visual Studio Code Azure Devops Git
  3. Azure Devops Visual Studio Code Tutorial
  4. Azure Devops Repos Visual Studio Code

We recently had the need for one of our testing folks to be able to access DevOps API to get more information from DevOps Test Plans. He tried to get the information he was needing thru built in reports and even connecting Power BI to DevOps but still wasn’t able to get at what he needed. He discovered he could get the information he was after by using DevOps API and OData queries.

I'm quiet new to C# and Azure functions and don't know how to properly implement this in my own project. I would really appreciate it if someone could guide me into the right direction. I am using Visual Studio with.NET Core 3.0 and Azure Functions. Here is the code so far. This VS Code extension adds syntax highlighting and autocompletion for Azure Pipelines YAML to VS Code. It also helps you set up continuous build and deployment for Azure WebApps without leaving VS Code. Basic YAML validation is built in to VS Code, but now you can have syntax highlighting that's aware of the Pipelines YAML schema. Browse other questions tagged c# visual-studio-code azure-devops nuget or ask your own question. The Overflow Blog Podcast 331: One in four visitors to Stack Overflow copies code. Podcast 332: Non-fungible Talking. Featured on Meta Stack Overflow for Teams is now free for up to 50 users, forever.

Studio

Problem was that he didn’t have the proper tools to call the API other than just Chrome browser. Normally our Integration developers will use Postman to connect, develop and test against API connections, but they do this using Azure Virtual Desktops. Our corporate machines are locked down (no local admin access) so users can’t install software on them. Our tester doesn’t have access to an Azure Virtual Desktop we we need to find another option.

Step 1: Find a client

I’m a big fan of Visual Studio Code (VSC) and was delighted to find out we could use it to test our Rest calls. The great thing about VSC is you do not have to have local admin rights to install it! Out of the box VSC does not have a rest client, but another great feature of VSC is all the extensions that you can install on it.

One of these extensions is Rest Client by Huachao Mao, the extension allows you to make HTTP requests and see the responses. It has almost a million downloads and 5 stars so you know it’s a good extension. It has really good documentation as well.

Azure

Step 2: Authentication

The rest client has a lot of different authentication options, so I first attempted to get it working with Azure Active Directory. But unfortunately when trying to connect I was getting the following error:

Azure Devops Visual Studio Code Integration

So we needed to have this endpoint added an an application in Azure Active Directory. I don’t have the proper permissions to do this at my company and wasn’t patient enough to get it created thru the proper channels. Luckily a colleague reminded me of Personal Access Tokens (PAT) in Azure DevOps. Personal Access Tokens allow you to create a token that you can then use use to connect to Azure DevOps.

Follow Microsoft’s documentation here to create a PAT:
https://docs.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate

Visual Studio Code Azure Devops Git

Devops

Step 3: Send API Request

To create the request, Create New File in VSC and be sure to change the file type to “HTTP”.

Azure Devops Visual Studio Code Tutorial

Here is the script we run to get a specific Test Plan via the API:

Azure

You will need to update this script with your Company ID, Project ID and the PAT you created in the previous step. As well in this query, this will return a Test Plan by the ID you specify.

Code

When using the Rest Client, you will see a “Send Request” appear above our “GET” Verb.

After running the request, your response will open up on right side (or below based on your settings), with the results of your query.

Step 4: Send OData Request

Just like calling API’s like in Step 3, here is the script to make an OData Query.

Conclusion

Hopefully this gives you a good sample of how you can use Visual Studio Code as a Rest Client to do some developing and testing against API’s. In particular in this case this shows you how to make API calls and OData queries against Azure DevOps Test Plans.

Let me know if this was helpful.

Azure Devops Repos Visual Studio Code

Related