Azure

How to deploy your Spring Boot Application to Azure Spring Cloud

This article explains how to deploy your Spring Boot Application to Azure Spring Cloud. Azure Spring Cloud is a serverless microservices platform that enables you to build, deploy, scale and monitor your Spring Boot Application with ease.

Create a new Azure Spring Cloud Resource

You can deploy to either existing resource group or create a new resource group:

At the time of writing this tutorial, there are two pricing plans available for Azure Spring Cloud:

For the purposes of this tutorial, we will go with selecting the Basic Plan.

Next, we can enable log Analytics for Azure Spring Cloud we are creating.

You can view up-to-date pricing for Azure Log Analytics here.

Next, we can enable distributed tracing by either creating new or connecting existing Azure Application Insights instance.

We also do have an option to deploy this Spring Cloud Application on our own Virtual network. This can be done by setting the toggle for the following setting to yes.

For the purposes of this tutorial, we will skip creating new Virtual Network.

Once, all these settings are setup we are good to hit the Review & Create button to deploy our new Azure Spring Cloud Resource.

While your resources are being deployed, you will see a screen like this:

Once the deployment is succesful and you navigate to the resource, you will see the following screen:

Now in order to get started there are several ways:

  • Link a default repository to deploy to Azure Spring Cloud
  • Deploy via Azure CLI
  • Deploy via Azure Portal

Let’s explore both these options in depth.

Link a default repository to deploy to Azure Spring Cloud

This is very simple. Simply go to the “Config Server” blade and enter the repository details.

Once this is done, hit the Apply button on the top left to apply the changes. This will deploy the application to the server.

Deploy Azure Spring Cloud Application via Azure CLI

Step 1: If you don’t have already, you will need to install the Azure Spring Cloud Extension for Azure CLI

az extension add --name spring-cloud

Step 2: Build the project using Maven

mvn clean package -DskipTests

Step 3: Deploy the JAR file to the Azure Spring Cloud App

az spring-cloud app deploy -n [app name] -s [service instance name] -g [resource group name] --jar-path target\path-to-jar.jar

It might take some time to get the application deployed. Once the application is deployed, you can go to the “Apps” blade on the Azure portal to see the status of the application.

Deploy Azure Spring Cloud Application via Azure Portal

To deploy an Azure Spring Cloud application via Azure Portal, navigate to the Apps blade shown in the screenshot above. You can potentially create multiple apps together.

Here, you can also configure vCPU, Memory and Instance count for each application.

Then, click the “Create App” button.

Once these apps are created, you can see them in the Apps Blade.

As you can see in the screenshot above, I have multiple Apps deployed running on different runtimes (Java 11 and Java 8) together on the same Azure Spring Cloud.

When you click on the Application from the list you can see the metrics, assign endpoint, change configuration for that particular application.

When you click on “Assign Endpoint” button, Azure will assign a default endpoint to your Azure Spring Cloud Application.

Assigning endpoint to Azure Spring Cloud
Assigning endpoint to Azure Spring Cloud

When you navigate to the test endpoint which looks like:

https://primary:[random-string][app-name].test.azuremicroservices.io/[app-name]/default/

You will see the following screen:

Once your App is deployed, you can also see the application running on the following endpoint:

https://[service instance name]-[app name].azuremicroservices.io

Leave a Reply