How to deploy Spring Boot app to Azure App Service?
Tags: cloud, springboot, microservices, devops
Published: 2020-10-24 02:52:30

If you are building Java based spring boot app, but struggling to deploy app to Azure Cloud? This blog post is for you, It will provide brief introduction of Azure App Service and App service Plans and the step-by-step guide to deploy Java based Spring boot app to Azure App service.

**What is Azure App Service?**

Azure App Service is a Platform as a Service offering from Microsoft Azure Cloud, which allows developer to focus on developing new business features and not worrying about running and managing the underlying infrastructure. Azure Service Fabric provides the underlying magic for App Service including all good things that comes with cloud - scaling, availability and redundancy.

![Azure App Service - Diagram](https://dev-to-uploads.s3.amazonaws.com/i/dyaobpsqvn7vn2el0441.JPG)

**Benefit of  using Azure App Service :**

* Faster time to market to compete in modern digital transformation powered innovation and disruption
* Deployment slots are live apps with their own host names. App content and configurations elements can be swapped between two deployment slots, including the production slot. Allows to test deployment in staging before moving to production and then swap staging to be production without additional cost
* Security is integrated within App Service - offers layered security like Multi-factor authentication (MFA) and other security features like authentication.

**App Service Plans:**

An App Service Plan is like a container in which your web applications run. it is used to determine the computing resources (CPU, RAM, Cache, disk space, etc.) available to your application. 

Following image shows comparison of various App service Plans such as Free/Shared, Basis, Standard, Premium and Isolated & their pricing.

![App service Plan - Comparison](https://dev-to-uploads.s3.amazonaws.com/i/iktocnwdjgnuxmi8l6xz.JPG)

**Maven Plug-in for Azure App Service:**

The Maven Plugin for Azure App Service helps Java developers to deploy Maven projects to Azure App Service. 

Pre-requisites before using this maven plug-in, 
* Install Azure CLI ( Refer this [link](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) )
* Sign in to Azure Portal using below command. 

![az login command](https://dev-to-uploads.s3.amazonaws.com/i/k9bikdubjn0xxy75q9h7.JPG)

**Deploy Spring Boot app (Java based) to Azure App service:**

Once above Pre-requisite steps are completed, 
* Using IDE (Eclipse/ IntelliJ) for Spring boot maven project, add  azure maven plug-in in pom.xml file.

Typical configuration for Azure Maven plug-in for Java based spring boot app is as below (You can select an existing Azure Web App or create a new one on prompt. Below snippet is for using existing App service Plan and App Service).

![Azure App Service - Maven Plugin configuration](https://dev-to-uploads.s3.amazonaws.com/i/b97bvai0vegbb5tt619x.JPG)

* Deploy your Java app to Azure using the following command

![Azure App Service - maven deploy](https://dev-to-uploads.s3.amazonaws.com/i/nsaced012tawkf5rzb8a.JPG)

* Finally, Navigate to Azure Portal -> Resource Group -> App Service which was used to deploy Java application and verify the App is running. 

**Conclusion**

Azure App Service provides fully managed platform for building, deploying and scaling your web apps  - Platform-as-a-Service. It greatly speeds up deployment of Spring boot based Java application to Azure App Service. 

Happy coding ! 

Please like, share and comment your views/ opinion.

Disclaimer - This post is my personal opinion and does not reflect those of any of my past, present or future employers or affiliations.