How to Generate Swagger File For Azure Java Function - spring

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
How to craete Azure HttpTriggerr Java function project with Springboot Application?
How to add Swagger Configuration to it?

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.
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
Next is to deploy the function code to Azure Function App:
./mvnw azure-functions:deploy
Result:
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:

Related

How to deploy Simple Java Spring boot application into Azure Web Job?

I have a simple spring boot application with controller class having Rest API's. Now I want to deploy this Java Spring application into Azure Web Job and trigger manually.
In Microsoft documentation (https://learn.microsoft.com/en-us/azure/app-service/webjobs-create) the details of deploying application written in .NET and C# is provided but I could not find anything related to Java or Spring boot App deployment into Azure Web job.
Can anyone please let me know the steps to be followed for deploying Spring boot app into Azure Web Job or Attach any documentations for reference?
Thanks & Regards,
Preethi H R
To execute the Java web jobs on Azure, I have followed the MSDOC.
created a Java spring boot Project and compressed into zip file.
Open Azure Portal, navigate to App Service page of your App Service web app and select Webjobs and add a new Webjob by providing required settings as specified below:
On the WebJobs page, select Add.
Fill the details in Add WebJob settings as specified in the table.
File Upload: Upload Executable or script file which has been converted to zip file (Springboot_H2_database_CRUD.zip).
Create a manually triggered WebJob
select WebJobs in Azure App service, create a new web job by selecting Type as Triggered in the settings and select Manual in Triggers.
Select OK.
To run the WebJob, click on the webjob name and select Run.
Create a scheduled WebJob
A scheduled Webjob is also triggered. You can schedule the trigger to occur automatically on the schedule you specify.
Select OK and Run the newly created webjob.
Desired execution frequency can be configured for the web job.

Spring Boot Webflux (reactive web app) not serving static content on file system

Issue
When setting the spring.web.resources.static-locations configuration as detailed in section 4.7.2 Static Content of the spring boot 2.4.2 reference guide, content is not found.
Steps to reproduce
Open the Spring Initialzr, select Project=Maven project, Language=Java, Spring Boot=2.4.2, Packaging=Jar, Java=8, Dependencies=Spring Reactive Web
Run the generated app with environment variable, the path below points to a valid folder containing an index.html file
export SERVER_PORT=8084
export SPRING_WEB_RESOURCES_STATICLOCATIONS=file:C:\mydev\staticlocal
mvn spring-boot:run
Open http://localhost:8084 , http://localhost:8084/ or http://localhost:8084/index.html with a browser and you get a Whitelabel Error Page
Alternative 1
Repeating the steps above by setting the configuration spring.resources.static-locations in step 2) as below will also fail to open the linked static files:
export SPRING_RESOURCES_STATICLOCATIONS=file:C:\\mydev\\staticlocal
Alternative 2: this works
Repeating the steps by selecting Dependencies="Spring Web" in step 1) and setting the configuration spring.resources.static-locations as below will succeed to open the static files:
export SPRING_RESOURCES_STATICLOCATIONS=file:C:\\mydev\\staticlocal
The problem above stems from the shell used to execute the scenario. See details in https://github.com/spring-projects/spring-boot/issues/25397
The Spring framework works as documented :)

DIfference between Application and Integration service in IIB

Could anyone please explain the difference between application and integration service in IIB. I have referred through documentation but it was not clear. For example, if I have to create a service based on wsdl which has some 3 operations.Should I create it as integration service or application.Please suggest
So with an Application it's roll your own in that you have to build everything.
With an Integration Service you can import a WSDL and the framework of your flow will be generated for you.
So if you are being given WSDL's for the services you want to build then using an IS may be the way to go.
Personally I don't like some of the aspects of the generated code but that's me. I'm currently working on a project that uses REST API's and am using the REST API project option for my projects and it generates code.

Build a Java Rest API with Intellij

I need help developing a Basic Java Rest API using IntelliJ and terminal on my mac. I also have docker installed. I want to run a hello world on local host using the REST API Style
There's a ton of different java web frameworks that will help you build a REST endpoint. Here's some of those frameworks:
http://spring.io/
https://vertx.io/
https://www.playframework.com/
if you want to build it from scratch (not recommended) then checkout
https://www.tutorialspoint.com/servlets/servlets-first-example.htm

How to build an Angular2 type script with spring boot back end in STS

I am learning angular 2 currently and trying to hosted in springboot java application.
I created a separate project using angular cli , then I created spring starter project with web only.
Next I imported the angular cli project inside /src/main/resources/static directory.
when I opened the browser , I was not able to see the basic index.html.
Then I removed all the imported files and imported only the content of the directory , which is the resulting compiled ES5 java script after transpiling the type script files in directory, this time it worked.
My questions are:-
1) What is the best practice , to use the GUI under /src/main/statis or create /src/main/public or /src/main/webapp ?
2) Does spring understand only js and not ts ( java script and not type script)?
3) Do I need a maven plugin for typescript and if so how to tell maven bundle the compiled js with the spring war while excluding the rest directories and files
4) How to include the testing unit / e2e with maven build
I searched for step by step guide for ANgular 2 and spring boot but could not find one. It would be helpful to many if some guide like this exist.
Many thanks for your support guys.
1) What is the best practice , to use the GUI under /src/main/statis or create /src/main/public or /src/main/webapp ?
Since typescript compiles to JavaScript I strongly recommend using GULP. I have my source files under src/client and I build with gulp to add the files to src/main/public
I believe either public or webapp works and there's not a huge difference.
2) Does spring understand only js and not ts ( java script and not type script)?
The newer version of STS has support for typescript, but I prefer to use visual studio code when viewing typescript files as there is better support.
3) Do I need a maven plugin for typescript and if so how to tell maven bundle the compiled js with the spring war while excluding the rest directories and files
If you use gulp, the typescript is compiled to js and added to the src/main/public directory where your springboot app sees the files when running with maven.
4) How to include the testing unit / e2e with maven build
I searched for step by step guide for ANgular 2 and spring boot but could not find one. It would be helpful to many if some guide like this exist.
Many thanks for your support guys.
I recommend using an angular seed or starter, this seems like the most up to date one that I've found:
https://github.com/antonybudianto/angular2-starter
This uses gradle, but is spring boot and angular 2:
https://github.com/borysn/spring-boot-angular2
I shared a project on github that integrates Angular 2 With spring boot. Just need to follow the step on readme or check commit history. You can access here Angular 2 with spring boot

Resources