Deploy a Quarkus web app to Azure App Service with Maven
In this quickstart, you use the Maven Plugin for Azure App Service Web Apps to deploy a Quarkus application to Azure App Service on Linux. Choose Java SE deployment over Tomcat and WAR files when you want to consolidate your app's dependencies, runtime, and configuration into a single deployable artifact.
If you don't have an Azure subscription, create a free account before you begin.
Prerequisites
- The Azure CLI, either locally or through Azure Cloud Shell.
- A supported Java Development Kit (JDK). For more information about the JDKs available for use when developing on Azure, see Java support on Azure and Azure Stack.
- Apache Maven, version 3.
Sign in to the Azure CLI
The simplest and easiest way to get the Maven Plugin deploying your Quarkus application is by using the Azure CLI.
Sign in to your Azure account by using the Azure CLI:
az login
Follow the instructions to complete the sign-in process.
Create sample app from the MicroProfile Starter
In this section, you create a Quarkus application and test it locally.
Create a Java SE 8 base project
Open a web browser and navigate to the MicroProfile Starter site.
Provide the following values for the indicated fields:
Field Value groupId com.microsoft.azure.samples.quarkus artifactId quarkus-hello-azure MicroProfile Version MP 3.2 Java SE Version Java 8 MicroProfile Runtime Quarkus Examples for Specifications Metrics, OpenAPI Select DOWNLOAD to download the project.
Unzip the archive file by using the following command:
unzip Quarkus-hello-azure.zip
Create Java SE 11 base project
To create the Java 11 base project, use the following command:
mvn io.quarkus:quarkus-maven-plugin:2.6.1.Final:create \
-DprojectGroupId=com.microsoft.azure.samples.quarkus \
-DprojectArtifactId=quarkus-hello-azure \
-DclassName="com.microsoft.azure.samples.quarkus.App" \
-Dpath="/hello"
Run the application in a local environment
Change the directory to the completed project by using the following command:
cd quarkus-hello-azure/
Build and run the project by using the following Maven command:
mvn quarkus:dev
Test the web application by browsing to it locally using a web browser. For example, you could use the following command if you have
curl
available:For a Java SE 8 project:
curl http://localhost:8080/data/hello
For a Java SE 11 project:
curl http://localhost:8080/hello
You should see the following message displayed: Hello World or hello.
Configure the Maven plugin for Azure App Service
In this section, you configure the Quarkus project pom.xml file so that Maven can deploy the app to Azure App Service on Linux.
Open the pom.xml file in a code editor.
In the
<build>
section of the pom.xml file, insert the following<plugin>
entry inside the<plugins>
tag aftermaven-surefire-plugin
.<plugin> <groupId>com.microsoft.azure</groupId> <artifactId>azure-webapp-maven-plugin</artifactId> <version>2.13.0</version> </plugin>
To configure the deployment, run the following Maven command:
mvn azure-webapp:config
Select the following options when prompted:
Input Field Input/Select Value Choose a subscription Enter your subscription ID. Define value for OS(Default: Linux): 2. linux Define value for javaVersion(Default: Java 8): 2. Java 11 Define value for pricingTier(Default: P1v2): 3. P1v2 Confirm (Y/N) y This command produces output similar to the following example:
[INFO] Scanning for projects... [INFO] [INFO] ------< com.microsoft.azure.samples.quarkus:quarkus-hello-azure >------- [INFO] Building quarkus-hello-azure 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- azure-webapp-maven-plugin:2.13.0:config (default-cli) @ quarkus-hello-azure --- [INFO] Auth type: OAUTH2 Username: abc@xyz.com Available subscriptions: * 1: Subscription1(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx) 2: Subscription2(yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyy) Please choose a subscription [xxx]: 1 [INFO] Subscription: Subscription1(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx) Define value for OS [Linux]: 1: Windows * 2: Linux 3: Docker Enter your choice: 2 Define value for javaVersion [Java 8]: * 1: Java 8 2: Java 11 3: Java 17 Enter your choice: 2 Define value for pricingTier [P1v2]: 1: D1 2: B3 * 3: P1v2 4: P1v3 5: P2v2 6: P2v3 7: P3v2 8: P3v3 9: B1 10: B2 11: F1 12: S1 13: S2 14: S3 15: EP3 16: EP2 17: EP1 18: Y1 19: FC1 Enter your choice: 3 Please confirm webapp properties Subscription Id : xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxx AppName : quarkus-hello-azure-1601011883156 ResourceGroup : quarkus-hello-azure-1601011883156-rg Region : centralus PricingTier : P1v2 OS : Linux Java : Java 11 Web server stack: Java SE Deploy to slot : false Confirm (Y/N) [Y]: [INFO] Saving configuration to pom. [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 16.502 s [INFO] Finished at: 2020-09-25T14:31:34+09:00 [INFO] ------------------------------------------------------------------------
Add the
<appSettings>
section to the<configuration>
section ofPORT
,WEBSITES_PORT
, andWEBSITES_CONTAINER_START_TIME_LIMIT
. Your XML entry forazure-webapp-maven-plugin
should look similar to the following example:<plugin> <groupId>com.microsoft.azure</groupId> <artifactId>azure-webapp-maven-plugin</artifactId> <version>2.13.0</version> <configuration> <schemaVersion>V2</schemaVersion> <resourceGroup>microprofile</resourceGroup> <appName>quarkus-hello-azure-1591836715762</appName> <pricingTier>P1v2</pricingTier> <region>centralus</region> <runtime> <os>linux</os> <javaVersion>java 11</javaVersion> <webContainer>java SE</webContainer> </runtime> <appSettings> <property> <name>PORT</name> <value>8080</value> </property> <property> <name>WEBSITES_PORT</name> <value>8080</value> </property> <property> <name>WEBSITES_CONTAINER_START_TIME_LIMIT</name> <value>600</value> </property> </appSettings> <deployment> <resources> <resource> <directory>${project.basedir}/target</directory> <includes> <include>*.jar</include> </includes> </resource> </resources> </deployment> </configuration> </plugin>
Add the following entry to the src/main/resources/application.properties file to create the uber-jar, also known as a fat Jar:
quarkus.package.type=uber-jar
Deploy the app to Azure
After configuring all of the settings in the preceding sections of this article, you're ready to deploy your web application to Azure. To do so, use the following steps:
If you made any changes to the pom.xml file, rebuild the JAR file by using the following command:
mvn clean package
Deploy your web app to Azure by using the following command:
mvn azure-webapp:deploy
If the deployment succeeds, you see the following output:
[INFO] Successfully deployed the artifact to https://quarkus-hello-azure-1591836715762.azurewebsites.net
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:20 min
[INFO] Finished at: 2020-06-11T10:06:51+09:00
[INFO] ------------------------------------------------------------------------
Maven deploys your web application to Azure. If the web application or web application plan doesn't already exist, it's created for you. It might take a few minutes before the web application is visible at the URL shown in the output. Navigate to the URL in a web browser. You should see the following screen:
After your web application is deployed, you can manage it through the Azure portal.
Your web application is listed in the microprofile resource group.
You can access to your web application by selecting Browse in the Overview page for your web app. Verify that the deployment was successful and is running.
Confirm the log stream from the running App Service
You can use the following command to view - or tail - the logs from the running App Service. Any calls to console.log
in the site code are displayed in the terminal.
az webapp log tail
--resource-group microprofile \
--name quarkus-hello-azure-1601011883156
Clean up resources
When the Azure resources are no longer needed, clean up the resources you deployed by deleting the resource group. To do so, use the following steps:
- From the Azure portal, select Resource group from the menu.
- Enter microprofile in the Filter by name field. The resource group created in this tutorial should have this prefix.
- Select the resource group created in this tutorial.
- Select Delete resource group from the menu.
Next steps
To learn more about MicroProfile and Azure, continue to the MicroProfile on Azure documentation center.
Additional resources
For more information about the various technologies discussed in this article, see the following articles: