Skip to content

Maven Plugin for deploying Springboot (or) other java projects to Azure API apps

Notifications You must be signed in to change notification settings

Muthuveerappanv/Azure-Deployment-Plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure-DeploymentPlugin

Maven Plugin for deploying Springboot (or) other java projects to Azure API apps

Short Description:

Azure does not provide any maven plugin or jenkins plugin to deploy applications onto the Azure API or Web Apps. This plugin helps deploy binaries in the Azure API or Web Apps by using the Azure AD Oauth app & FTP.

STEP 1 > Create Azure AD Oauth App & provide access to API App's ResourceGroup

  • To create a Oauth App in Azure AD, go to Azure Active directory in the navigation pane & click on New-Application-Registration

    Alt text

  • After Creating the App select Required Permissions on the app to add 'Windows Azure Service Management API' and provide all required permissions. (read - write). This ensures that the AD oauth app has access to the Azure Service Management APIs (start/stop Api/web App)

    Alt text

    Alt text

  • After granting permissions, access keys needs to be generated & saved as it is visible only during creation

    Alt text

  • Detailed Explanation of the Azure API app is provided in the following flow : https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-integrating-applications

Before adding resource group, make sure we have the following:

  • Application ID (Client ID) (From previous steps)
  • Client Password (From previous step)
  • Tenant ID - refer below screenshot

Go to Azure Active Directory -> Properties -> Directory ID Alt text

Last process is to got to provide ResourceGroup access to this particular AD app. Make it the owner or provide modifier access as shown below

Alt text

Setup the deployment credentials & save them for using further: https://docs.microsoft.com/en-us/azure/app-service/app-service-deployment-credentials

STEP 2 > Building & deploying Apps

Projects:
  1. azure-deployment-plugin - Maven Plugin which needs to be added to the project that needs to be deployed in the azure api app
  2. hello-world-sb - Simple hello world springboot application that needs to be deployed in Azure with a configuration in pom.xml to add the custom maven plugin (abiove)

Build procedure:

  • Run a 'mvn clean install' on the root folder of this repository.
  • Once successful build move onto the sample application. open the pom.xml & provide the Application & Azure specific values

ftpCredentials -> '<<username>>::<<password>>'

Alt text

Configuration Description
appName Application name in Azure
clientId Azure AD Oauth App's Client Id
clientPassword password associated with the Oauth App
ftpCredentials Azure deployment credentials - username::password (format)
ftpHostName Azure api app's ftp hostname
resourceGroup Azure Api App's resource group
tenantId Azure AD Tenant ID
subscriptionId Azure API app's subscription ID
Procedure:

On completing the above configuration, assuming that the project is already built & the binary is available in the target folder:

  1. Run the custom maven command azure-deploy:deploy from the 'hell-world-sb' project to push the jar file to the azure cloud via FTP.
  2. Ensure that the FTP ports are not blocked in your network.
  3. Continuous deployment is enabled by default. If there is an existing deployment already available, then the plugin does the below:
  • Stops the application
  • push the jar onto a temp directory
  • moves the current deployment into backup folder & renames with timestamp (creates backup dir if not present)
  • moves the new jar to the root folder
  • on successful completion of above steps - starts the application back, on any exception - still holds on to the existing deployment already available
  • clears the temp directory.

Concept Inherited from - https://docs.cloudfoundry.org/devguide/deploy-apps/blue-green.html

API APP screenshots:

Simple API app tied to a app-service-plan:

Alt text

On Successful Deployment (see the following output)

Alt text

Sample web.config for deployment is attached :

web.config - Uses Java8 for supporting springboot in Azure API App.

About

Maven Plugin for deploying Springboot (or) other java projects to Azure API apps

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages