Deploying to Microsoft Azure

Microsoft Azure

Deploying JHipster applications to Microsoft Azure are as easy as deploying Docker containers. Azure supports the deployment of Uber JARs, WAR files, and Docker images, either as standalone or orchestrated on top of Kubernetes. Sub-generators are not needed for the deployment choices documented below.

Developers can obtain an Azure Trial subscription and perform all the deployment options below with the free credits provided to the trial account. Some of the services covered below also offer a free quota based on hours of compute and/or number of applications, that will not incur consumption of the granted free credits.

For web applications, the best service to get started with is Azure App Service, and in general Azure comes with three key ways to deploy applications: (1) using the Azure Dashboard; (2) using the Azure CLI or; (3) using the Maven Plugin.

This documentation covers some of these methods, but not all of them and not all possible services either. For more details, check the Azure Documentation website.

Currently, Azure does not provide plugins for Gradle, so therefore some of the instructions below will be specific to Maven projects, while others can be done with the Azure CLI and other command-line tools.

Supported Databases

JHipster applications configured to the following databases will find services that provide these data storage solutions:

Before you start

Install and authenticate with the Azure CLI on your local environment. For more information, visit these links:

Monolithic JHipster Applications

Monolithic applications are the easiest to deploy, as usual. In this section we will explore how to deploy Jar artifacts from JHipster projects using the Apache Maven Plugin for Azure App Service for Web Apps:

Executable Jar files

Azure App Service supports running executable Jar files as generated by JHipster.

To proceed with the deployment, follow these steps:

  1. Add the following Maven Plugin configuration to your main <build> element of your pom.xml:
                 <!-- check Maven Central for the latest version -->
                     <region>France Central</region>

    Be careful, the attributes resourceGroup, appName, pricingTier and region must be configured with correct project values.

  2. As you will probably use a database, do not forget to modify the application-prod.yml file accordingly, for example with an Azure MySQL database:
         url: jdbc:mysql://
         username: jhipster@jhipster
         password: MyPasswordToChangeInProduction
  3. Build the project with the following command, as usual for a JHipster production build:
         ./mvnw clean package -Pprod
  4. Deploy the application:
         ./mvnw azure-webapp:deploy

For up-to-date information about the Maven Plugin for Azure App Service, check the documentation.

Docker-based Monolithic Application

To deploy your monolithic application as a Docker container to Azure, the ideal and simplest solution is to run it on Azure Container Instances (ACI), which provisions Docker containers almost instantaneously. But for this you will first have to create an Azure Container Registry (ACR). You can also push your image to your Docker Hub repository and create a Docker container on ACI by pulling the image from there, but this method is insecure since your Docker image may be public to anyone to download and you risk having credentials (e.g. to databases) in your application.

Once you have an ACR created, you can generate your JHipster Docker image and push to it to later use that image on Azure Container Instances. Let’s see how this works:

  1. Imagine you have a JHipster application called myjhipsterapp.
  2. Build a Docker image for your monolithic JHipster project:
         ./mvnw package -Pprod jib:dockerBuild
  3. Tag and push your generated Docker image to your ACR instance. For example:
         docker tag myjhipsterapp:latest <your-acr-server>/myjhipsterapp:latest
  4. Make sure your Docker CLI is authenticated to your ACR
         az acr login --name <acrName>
  5. Push your image to your ACR instance:
         docker push <your-acr-server>/myjhipsterapp:latest

Now that your image is available on your Azure Container Registry, you can create a Docker container based on it on Azure Container Instances. For a complete step-by-step, please refer to the documentation. The steps below are for simplicity and should not be used in production:

  1. Enable admin:
         az acr update --name <acrName> --admin-enabled true
  2. Retrieve password to authenticate ACI against ACR:
         az acr credential show --name <acrName> --query "passwords[0].value"
  3. Deploy a container with 1 CPU core and 1 GB of RAM:
         az container create --resource-group myResourceGroup --name myjhipsterapp --image <acrLoginServer>/myjhipsterapp:latest --cpu 1 --memory 1 --registry-username <acrName> --registry-password <acrPassword> --dns-name-label myjhipsterapp --ports 8080

Docker containers on Kubernetes

To deploy your JHipster Microservices to Kubernetes on Azure, all you need to do is to create an Azure Kubernetes Service cluster, and configure it to your local kubectl. After that, you can follow the generic JHipster on Kubernetes documentation. Follow these documented steps for a complete walk-through.