Azure DevOps CI/CD — Creating CD to deploy Docker Image in App Service

Vicky AV
4 min readJun 16, 2020

--

Azure DevOps CD to deploy Docker image of Spring Boot Application into Azure App Service

Deploy from DockerImage Azure Container Registry to Azure App Service

This is second among series of articles on how to build & deploy a SpringBoot Application into Azure App service using Azure DevOps CI & CD

I highly recommend to read Azure DevOps CI/CD — Creating CI for code hosted in Github article before reading this

Steps

  1. Lets create a new CD pipeline
  2. Time to create container registry
  3. Lets create a resource group
  4. Enter container registry details in CI pipeline

Lets create a new CD pipeline

  • Click on Pipelines -> Release -> New Pipeline
Choose Releases from Pipelines
  • In Select a template, choose Azure App Service deployment type & click Apply
Azure App Service Deployment helps deploying Docker images
  • Click on Add an artifact & choose the CI pipeline name
Choose your build pipeline name
  • Click on Job Task & choose the Azure Subscription from dropdown
  • To deploy in App service, we need to first create App service in Azure DevOps portal. Lets do that step & come back to our CD pipeline setup

Creating App Service in Azure DevOps

Add new App Services
  • Choose the same resource group you used for Azure Container Registry (In my case its ci-cd-demo-rg
  • I choose the name ci-cd-demo-webapp for webapp
  • In publish, choose Docker Container option
Creating new app service for Docker deployment
  • Click Next & choose the image source as Azure Container Registry
  • If you see the error “Cannot perform credential operations for subscriptions” like below, Go to Container Registry & click on Access Keys under settings & enable admin user
  • Now you can choose the Docker Image name from the drop down
  • Now finish the next steps by not changing any default settings & click create to create your first App Service
  • We should see Deployment is complete message at last
Deployment complete denotes successful creation of App Service

Now time to go to back our CD pipeline

  • Click on the stage name & choose Azure Subscription & App type as Web App for Container (Linux). Remember ! Unless we choose a right App type, we won’t see our app service in App Service name dropdown
  • Choose the app service we just created
  • Enter the registry name (refer from Azure container registry portal) & repository name (refer from your CI pipeline)
  • Since I already given ENTRYPOINT in my Dockerfile, I skipped the startup command
  • By default, Azure app service will be trying to expose PORT 80 only. Since SpringBoot runs the application in 8080 by default, we have to configure WEBSITE_PORT value in app settings
  • In order to do it, Go to Deploy Azure App Service task & expand Application and Configuration Settings. In App settings, add a new entry like below
  • Verify everything in Deploy Azure App Service task & click on Save button
Verify everything in Azure Service Name
  • Once save is complete, click on Create Release button & choose the stage (we have only one stage as of now Stage 1) & hit create button
  • Now your deployment should have started already by taking latest artifact from CI
Deployment in progress
  • Once deployment in complete with either success/failure, you can verify deployment logs here in CD pipeline itself.
  • But remember we can’t see application startup logs here. Only Deployment logs can be referred here
  • We can access our application by taking URL from Azure Portal -> Your Azure App Service -> Overview -> URL (in Right side top)

I enabled Spring Boot Actuator health check URL. By verifying health check, my application is running successfully

  • To see application logs, go to Azure portal -> Your Azure App Service -> Monitoring -> Log Streams

Thats all folks !

--

--