Azure Functions with Java is generally available.In this post, I’ll show you how to create Azure Functions with Java and Eclipse.This post assumes that you use Mac OS.Of course, you can with Windows.
At first, you need to install .NET Core. See the following links for details.
https://dotnet.microsoft.com/download
Next, you need to install Azure Functions Core Tools.Execute the following command in Terminal of Mac OS.
# brew tap azure/functions # brew install azure-functions-core-tools
In Eclipse, select the File menu, then select Project.
Open the Maven Project folder and select Maven Project, then select Next.
Select Next.
Click “Add Archetype…”.
Add the entries for the azure-functions-archetype.
- Archetype Group ID: com.microsoft.azure
- Archetype Artifact ID: azure-functions-archetype
- Version: Use latest version from the central repository
Select Next.
Enter the value based on the Maven Rules in the “Group Id” and “Artifact Id” fields and click “Finish”.
Maven creates the project files in a new folder with a name of artifactId. The follwing code is generated.This code is a simple HTTP triggered function that echoes the body of the triggering HTTP request.
Right-click on the generated project, then choose Run As and Maven build.
In the Edit Configuration dialog, Enter package in the Goals and Name fields, then select Run.
Once the build is complete, create another Run configuration to execute Azure Functions built previously.
In the Edit Configuration dialog, Enter “azure-functions:run” in the Goals and Name fields, then select Run.
The following messages get displayed in Console if execution is successful.
Http Functions: HttpTrigger-Java: [GET,POST] https://localhost:7071/api/HttpTrigger-Java
Add a query parameter “name” to the end of the URL as above and access the following URL.
https://localhost:7071/api/HttpTrigger-Java?name=noriyuki
You will see “Hello, noriyuki” on your Web Browser.