How to Install Swagger for .Net 2.2 Web API?

I had a “WTHek” time installing Swagger, the documentation tool.


So here is how to install Swagger in the right way.

Create a new Web API project.

Create a new Web API project in .Net Core 2.2

Ensure it is compiling fine.

Run Package Manager

Go to your Web API project & Run Package Manager command

Install-Package Swashbuckle.AspNetCore -Version 5.0.0-rc4

Install-Package Microsoft.OpenApi.Models

Add Code to ConfigureServices() method

Towards the last.

services.AddSwaggerGen(c =>
c.SwaggerDoc(“v1”, new OpenApiInfo { Title = “My API”, Version = “v1” });

// Resolve namespace for OpenApiInfo

Add Code to Configure() method


app.UseSwaggerUI(c =>

c.SwaggerEndpoint(“/swagger/v1/swagger.json”, “API V1”);



Run the Application


You should be able to access the Swagger documentation as below:


More Debugging

If you missed any [HttpGet] attributes also swagger will give above “swagger.json” error.

Open the Output window to view which Controller method is causing trouble.


Azure API Management

Following are the advantages of Azure API Management

Platform Independence enabling multiple clients to call the API through Standard protocols.

Service Evolution enabling adding new functionalities regardless of the clients.

Discoverability enabling documentation on existing services Discoverable by clients.

Backward Compatibility to ensure old version clients are still supported

Security prevents from automated attacks

Caching for faster & cost effective responses

API-First Approach enables Designing application with API consumption in mind.

RESTful enabling usage of HTTP & Common HTTP Verbs GET, PUT, POST, DELETE for CRUD operations, Stateless Request Model enabling easier Scalability.

Creating a VNET (Virtual Network) in Azure

VNET (Virtual Network)

VNET provides the following advantages:

  • Isolation by providing a subnet within the Azure
  • Protection from public Internet & Other VNETs

Create a VNET

We need to create 2 VNETs:

  • frontend VNET for the web application
  • backend VNET for the sql database

Open Azure Portal & Go to Create Resource > VNET.


We can create a frontend subnet now.


We can create a backend subnet now.

(Go to Home > Virtual Networks > Choose our VNET > Subnet blade)


You can see the Subnets have different Address ranges.


In the next post we can create a web application & host in the VNET.


In this post we can see how to create a VNET (Virtual Network) in Azure.

Azure Traffic Manager

Azure Traffic Manager resolves the DNS request into IP Address.  It is usable for Globally available applications where Users can access from different countries/regions. 

Routing Methods

Azure Traffic Manager does the routing based on 6 types of methods:

Priority where end point is chosen based on priority.

Weighted Routing where traffic is distributed evenly among endpoints.

Performance Routing where closet endpoint is chosen based on endpoint latency compared with the user location.

Geographic Routing where user is directed to the geographical region of their location.  It also aligns with Geo-compliance ensuring data is not crossing country boundaries.

Multivalue Routing where multiple endpoints are provided to a single DNS query response.

Subnet Routing where user IP address ranges to specific endpoints based on the Subnet of the user.


Azure Traffic Manager can be used for Failover scenarios too where Active/Passive model can be implemented – whenever Active server goes down the Passive will come into play.


In this post we have explored about Azure Traffic Manager.