Open API(Swagger) and Swagger UI on Azure Functions v2(C#)

I will explain an easy way to provide Open API and Swagger UI in Azure Functions v2.

  1. You install AzureFunctions.Extensions.Swashbuckle package with nuget.
install nuget package

2. You add startup code on your functions project.

3. You add Open API function and Swagger UI function.

You start DEBUG and access http://localhost:7071/api/swagger/ui on your browser.

swagger ui

Please add this API code to the project to try it out.

And start DEBUG and access swagger ui.

Next, The following describes the available Attributes.


If you want to set API result per Http Status, you use to ProducesResponseTypeAttribute.

ProducesResponseTypeAttirbute can multiple set.


If you want to set RequestBody, you use to RequestBodyTypeAttribute.

RequestBodyTypeAttribute must set in HttpRequest or HttpRequestMessage paramater.

RequestModelClass’s property can set data annotation.


If you want to set Http header, you use to RequestHttpHeaderAttribute.

RequestHttpHeaderAttribute can set multiple, and RequestHttpHeaderAttribute can set Class or Method.


This package collect all HttpTrigger functions and add in Open API.

If you have Http Trigger Functions that you do not want to add to Open Api, use SwaggerIgnoreAttribute.

Finally, I will introduce how to import XmlCommentDocument and add it to Open API.

If you want to add XML comments in the program code to the OpenAPI Description, do the next:

  1. Add this xml in to functions project’s csproj file.
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">

2. Change host.json. You add extensions setting.

"version": "2.0",
"extensions": {
"Swashbuckle": {
"XmlPath": "SampleFunction.xml"
include xml comment

Microsoft MVP Azure Technologies / / Xamarin / .NET / ASP.NET Core / Web Front End / Azure

Microsoft MVP Azure Technologies / / Xamarin / .NET / ASP.NET Core / Web Front End / Azure