Vignesh Arvind
Vignesh Arvind

Reputation: 611

DotNet 5.0 Swagger is not loading in Azure App Service

i have a web api which is created using dotnet 5.0 and deployed to Azure App Service, It is running and swagger loads successful, but in Azure App Service the swagger is not loading also throws 404 error but API data loads successfully.

Upvotes: 16

Views: 8878

Answers (1)

Jason Snelders
Jason Snelders

Reputation: 5661

Check your Startup.cs file and the Configure() method.
If you created a new .NET 5 project with Swagger automatically configured then it may only be enabled in the development environment.
Check if your code looks something like this:

if (env.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Lotus.API.Integration v1"));
}

Move the Swagger configuration lines outside the if statement and that should allow it to load in Azure (i.e. outside of your IDE).

Upvotes: 48

Related Questions