Azure Functions with RESTEasy Reactive, Undertow, or Reactive Routes
The quarkus-azure-functions-http
extension allows you to write microservices with RESTEasy Reactive (our Jakarta REST implementation), Undertow (servlet), Reactive Routes, or Funqy HTTP and make these microservices deployable to the Azure Functions runtime.
One azure function deployment can represent any number of Jakarta REST, servlet, Reactive Routes, or Funqy HTTP endpoints.
This technology is considered preview. En la preview, la compatibilidad con versiones anteriores y la presencia en el ecosistema no están garantizadas. Las mejoras específicas podrían requerir cambios en la configuración o en las API, y los planes para convertirse en estables están en marcha. Los comentarios son bienvenidos en nuestra lista de correo o como problemas en nuestro GitHub issue tracker. For a full list of possible statuses, check our FAQ entry. |
Por el momento, sólo se admiten los tipos de medios basados en texto, ya que Azure Functions HTTP Trigger para Java no admite un formato binario |
Requisitos previos
To complete this guide, you need:
-
Roughly 15 minutes
-
An IDE
-
JDK 11+ installed with
JAVA_HOME
configured appropriately -
Apache Maven 3.8.8
-
Optionally the Quarkus CLI if you want to use it
-
Optionally Mandrel or GraalVM installed and configured appropriately if you want to build a native executable (or Docker if you use a native container build)
-
Una cuenta de Azure. Las cuentas gratuitas funcionan.
-
Azure Functions Core Tools version 4.x
Solución
This guide walks you through running a maven project that can deploy a Resteasy Reactive endpoint to Azure Functions. While only Jakarta REST is provided as an example, you can easily replace it with the HTTP framework of your choice.
Creación del proyecto de implantación de Maven
You can download the example code from Quarkus’s application generator at this link.
You can also generate this example with the Quarkus CLI:
quarkus create app --extension=quarkus-azure-functions-http
Quarkus dev mode
Quarkus dev mode works by just running your application as a HTTP endpoint.
./mvnw clean package quarkus:dev
Run locally in Azure Functions simulated environment
If you want to try your app with a simulated local Azure Functions environment, you can use this command
./mvnw clean package azure-functions:run
Note that you must have the Azure Functions Core Tools installed for this to work!
Deploy to Azure
The pom.xml
you generated in the previous step pulls in the azure-functions-maven-plugin
. Running maven package generates config files and a staging directory required by the azure-functions-maven-plugin
. Here’s how to execute it.
./mvnw clean package azure-functions:deploy
Si el despliegue es un éxito, el plugin de azure le dirá la URL base para acceder a su función.
i.e.
[INFO] HTTP Trigger Urls:
[INFO] QuarkusHttp : https://{appName}.azurewebsites.net/api/{*path}
La URL para acceder al servicio sería
Extensión de las dependencias de maven
Debes incluir la extensión quarkus-azure-functions-http
ya que es un puente genérico entre el tiempo de ejecución de Azure Functions y el framework HTTP en el que estás escribiendo tus microservicios.
Descriptores de despliegue de Azure
Templates for Azure Functions deployment descriptors (host.json
, function.json
) are within the base directory of the project. Edit them as you need to. Rerun the build when you are ready.
Configuración de las rutas de acceso a la raíz
The default route prefix for an Azure Function is /api
. All of your Jakarta REST, Servlet, Reactive Routes, and Funqy HTTP endpoints must explicitly take this into account. In the generated project this is handled by the quarkus.http.root-path
switch in application.properties