38 C
Dubai
Tuesday, October 15, 2024

Deploy Spring boot App in Azure App Service with Azure DevOps

In this requirement. We are using CI / CD from Azure DevOps using Azure Repos and YAML files and creating an artifact, and deploying Java Spring Boot on Azure App Service using Azure DevOps Releases.

Good to know – CI/CD are Continuous Integration, Continuous Delivery, and Continuous Deployment.

Pipelines are integrated with Azure Repo for CI / CD and are deployed to Dev (Azure App Service ) from develop branch, where they can be tested. If it gets approved (Approval Gates), it will be deployed to the Production App Service after testing. Otherwise, the change can be rejected.

I ran the Java Spring boot locally using Extension Pack for Java, which went through successfully.

.

I have installed Eclipse as requested by Visual Studio Code

.

Run the AppApplication.java sits inside the controller folder.

.

.

Whatever port was declared in application.yaml file , its comes up in the localhost

.

Confirmed the site is online and coming up locally.

.

Repo stored Azure Repos / azure-pipelines.yaml is stored in Develop branch.

.

# YAML Pipeline - Azure DevOps
trigger:
  branches:
    include:
    - main
    - develop

pool:
  vmImage: 'Ubuntu-latest'

steps:
- task: Maven@3
  inputs:
    mavenPomFile: 'pom.xml'
    mavenOptions: '-Xmx3072m'
    javaHomeOption: 'JDKVersion'
    jdkVersionOption: '1.8'
    jdkArchitectureOption: 'x64'
    publishJUnitResults: false
    testResultsFiles: '**/surefire-reports/TEST-*.xml'
    goals: 'package'
- task: CopyFiles@2
  displayName: 'Copy Files to artifact staging directory'
  inputs:
    SourceFolder: '$(System.DefaultWorkingDirectory)'
    Contents: '**/target/*.?(war|jar)'
    TargetFolder: $(Build.ArtifactStagingDirectory)
- task: PublishBuildArtifacts@1
  inputs:
    pathToPublish: $(Build.ArtifactStagingDirectory)
    artifactName: SampleSpringBootBuild
.

As you see, the YAML is set to create an Artifact named SampleSpringBootBuild.
Now let’s use the artifact and deploy it to App Service.

Now lets create a pipeline using existing Azure Pipelines YAML file

.

Now Pipelines is running as expected.

.

Now let’s create a release pipeline to deploy the artifact to App Service.

.

Now create a Dev Stage to deploy the jar file, which is the artifact/package that needs to be pushed to Azure App Service.

.

Automatic Trigger is Enabled to have Continous CI/CD

.

You can see it’s released successfully to the app service. Using release pipelines

.

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?