Calling a REST API from Azure Release Pipeline
When releasing an application using the CI/CD cycle provided by the pipelines in Azure DevOps, there comes a time when every time the application is released, calling another existing REST API might be useful.
This handy feature could be used to automate the process of documenting the time when an application is released or to document all of the endpoints that an application has and put those data straight into a database. In this article, I’m going to show you a simple way to do just that.
First of all, add a new Agentless job to the deployment process and add a task called “Invoke a REST API”
Next, if there are no available Generic service connection already, click on the “Manage” button to create a new one.
In the Service Connections page, click the “New Service connection” button, pick Generic, and scroll to the bottom to click on Next.
Then, fill in the Server URL of the REST API that we wanted to hit. For this example, we want to make a POST request to an API that records the deployment time of other APIs, with the url https://someurl.com/api_documentation we would put in https://someurl.com and put in the service connection name, we can name it whatever we like and save it.
Finally, return to the tasks page and fill in the fields such as Method, Headers, Body, URL suffix and parameters according to the request that wanted to be made and click on save. Here is an example:
That’s it! Now every time the application is deployed, it would make an API request and send the provided data accordingly. Information about the current time can later be obtained from the logic inside the API.