Search code examples
springapiazure-functionsswaggerazure-java-sdk

How to Generate Swagger File For Azure Java Function


I Have Azure HttpTrigger Java functions(get, Post) Those are Working Fine in Postman but, as per the Client Requirement I need To create swagger UI file for all those functions(Java) i am searching Refference stuff from lastweek, stil i did not get it,So plese any one share/guide/help me

  1. How to craete Azure HttpTriggerr Java function project with Springboot Application?
  2. How to add Swagger Configuration to it?

Solution

    1. How to craete Azure HttpTriggerr Java function project with Springboot Application?

    Following this MS Doc, created the Azure Functions Http Trigger in Spring boot.

    1st Step is cloning the basic Function code of Sprint Boot Azure Functions Application. enter image description here

    Step 2: In pom.xml, you have to change these properties accordingly:

    <functionResourceGroup>HariTestRG</functionResourceGroup>
    <functionAppName>my-spring-function-app</functionAppName>
    

    Step 3: Clean and build the packages ./mvnw clean package and then run using the cmdlet ./mvnw azure-functions:run

    enter image description here

    Next is to deploy the function code to Azure Function App:

    ./mvnw azure-functions:deploy
    

    Result: enter image description here

    enter image description here

    1. How to add Swagger Configuration to it?

    Go to the Azure Portal > Deployed Function App > Click on API Management on left Index > Import the Function App APIs in APIM Instance > Then you'll see the Open API Definition which generates the swagger UI file for all the functions:

    enter image description here

    enter image description here