Java Function: Azure Serverless Deployment
This article covers the deployment of Java Function to Azure Functions, from validation and setup to testing and deployment.
Join the DZone community and get the full member experience.Join For Free
This article covers the deployment of Java Function to Azure Functions.
- JDK, version 8+.
- Apache Maven, version 3 or higher.
- Azure Account (free trial would suffice as well).
- Azure CLI.
- Azure Functions Core Tools.
Validating the Local Environment Setup
Verify Apache Maven version:
Verify Azure CLI:
Verify Azure Function Core tools:
Generate the code by using the Maven archetype. Go to a new directory and run the below command from the command line:
Provide the values as applicable to generate the project.
The file structure looks something like the below:
Go to Function.java.
@FunctionName defines the name of the function which is unique to the project. Below is an example of a function associated with Azure Functions.
Before testing locally, modify the local.settings.json as below to modify the port(default 7071)
Package the project:
Once the application is packaged, individual functions are exposed in the package with a manifest file, which defines how to trigger the jar.
Run the project locally:
Below will be the output in the console on successful startup:
Test the setup, by running the below command:
Deployment to Azure Function
In the command line, run the below command and login to the Azure account.
Deploy to Azure function using below command:
Verify the deployment by logging into the Azure Portal:
Test the Azure function by using curl or from the browser:
Opinions expressed by DZone contributors are their own.