Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 564
Vignesh Arvind Avatar asked Dec 21 '25 12:12

Vignesh Arvind


1 Answers

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).

like image 82
Jason Snelders Avatar answered Dec 23 '25 04:12

Jason Snelders



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!