How To: Use Swagger in Azure Functions

Even though Microsoft dropped the preview feature „Swagger document“, there is a community-driven package, based on the work of „Aliencube“, which provides the functionality for generating and rendering an OpenAPI document. In this how to we will discover how to implement a decorator-based OpenAPI.


We will use the following nuget packages for adding the functionality to our http-triggered Azure Functions:


Implement startup class for Swashbuckle

Since Azure Functions, by default, have no „Startup“ class like default .net Core Web API projects, we will implement the interface „IWebJobsStartup“ to add custom services to the app container:

Implement HTTP-triggered endpoints

For a full working OpenAPI UI via Azure Functions, we need to implement two endpoints:

  • An endpoint to return the JSON document
  • An endpoint to return the SwaggerUI

The first endpoint is named „SwaggerJson“:

The second endpoint is named „SwaggerUI“:

See results

If you have not changed anything in the routing, we can now call the default url: http://localhost:7071/api/SwaggerUI and look at our new SwaggerUI:

Happy coding! 🙂

Leave a Comment

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.