Reputation: 611
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
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