Azure Functions and in code Open API Configuration
    • Dark
      Light
    • PDF

    Azure Functions and in code Open API Configuration

    • Dark
      Light
    • PDF

    Article summary

    #ServerlessTips - Azure Functions
    Author: Mandar Dharmadhikiri Business & Integration Architecture Manager

    Azure Functions now support the code time open API documentation for the HTTP endpoints through the use of the Azure Functions OpenAPI Extension. You need to install the Microsoft.Azure.WebJobs.Extensions.OpenApi nuget package.

    You can then add the general API details using the IOpenApiConfigurationOptions as shown in following screenshots
    download 79

    download 80

    You can then register the configuration options in the Startup class as shown below

    download 81

    In order to define the APIs represented by the HTTP Triggered Azure Functions, each functions needs to be decorated with several attributes which define the request response bodies, status codes etc.

    download 82

    Once you run/deploy function app, you will see that there some extra functions that are deployed along with the azure functions that you write. Following screenshot illustrates the same

    download 83

    The Open definition can now be accessed using the RenderSwaggerUI endpoint. Sample shown below
    download 84

    You can now configure the OpenAPIConfigurationOptions and functions decorations as required, more details can be found at Azure Functions Open API Extension. It should be noted that when you use this option, you will deploying extra azure functions which will incur some extra billing.

    azure-functions1


    Was this article helpful?