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.
Asked
Active
Viewed 6,458 times
13
-
Did you resolve this? I have the same issue. – iandayman Feb 08 '21 at 11:02
1 Answers
40
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).

Jason Snelders
- 5,471
- 4
- 34
- 40
-
@Vignesh -- This should be accepted as the answer at this point as I've tried the answer myself and can verify it works. – KSwift87 Oct 07 '21 at 14:28
-