Deploy Web API to Azure API Management via Azure Devops CI/CD pipelines — Part 1
This series of tutorial, which consists of 3 following parts, will be demonstrating on how to deploy ASP.NET Web API endpoints at the same time update definition in Azure API Management through Azure Devops CI/CD pipelines:
Part 1: Configuring Web API project
Part 2: Create an instance of API Management and Web API on Azure
Part 3 : Create CI/CD Pipeline on Devops
Prerequisites:
- Microsoft Azure account
- Visual Studio 2022 (In this tutorial, we are using .NET6 project)
Sample Code is available at GitHub: https://github.com/hmheng/apimdemo
Part 1: Configuring Web API project
Step 1 — Create Web API
Step 2 — Build and run it to make sure it is working
Step 3 — Go to Web API project folder, open powershell/terminal and enter the following commands:
dotnet new tool-manifest
This would generate dotnet-tool.json manifest file.
dotnet tool install — version 6.2.3 Swashbuckle.AspNetCore.Cli
This would install the Swashbuckle.aspnetcore.cli to the dotnet tool.
Step 4 — Edit the .csproject file and add the following configuration line so swagger file would be generated.
<Target Name=”SwaggerToFile” AfterTargets=”AfterBuild” Condition=”’$(Configuration)’==’Release’”>
<Exec Command=”dotnet swagger tofile — output <preferred filename>.json "$(TargetPath)" "<API name> "” />
</Target>
Step 5— After adding the configuration, you should see refv1.json being generated.
Don’t forget to commit all the changes to Azure Devops.
Next: Part 2: Create an instance of API Management and Web API on Azure