Deploying to Azure App Service with Continuous Integration

Leverage the power of Azure App Service to host your web applications and automate deployments using Continuous Integration (CI). This guide outlines the steps to set up a CI pipeline, ensuring your code changes are automatically built, tested, and deployed to your App Service instance.

Why Continuous Integration?

Prerequisites

Setting Up Continuous Integration

1. Connect Your App Service to a Repository

Azure App Service integrates seamlessly with popular Git providers. You can configure this directly from the Azure portal.

Navigate to Your App Service

Go to the Azure portal and select your App Service resource.

Access Deployment Center

In the left-hand menu, under "Deployment," click on "Deployment Center."

Choose Your Source Control Provider

Select your Git provider (e.g., GitHub, Azure Repos, Bitbucket). You may need to authorize Azure to access your repository.

Deployment Center Source Control Options

Configure Repository and Branch

Select the repository containing your application code and the branch you want to deploy from (e.g., main or master).

2. Configure Build and Deployment Settings

Once connected, Azure App Service will guide you through configuring the build process. This typically involves specifying the build provider (like Azure Pipelines or GitHub Actions) and build settings.

Select Build Provider

Azure Pipelines is the default and recommended option for Azure Repos. For GitHub, you can choose GitHub Actions.

Define Build Pipeline

Azure will automatically detect your project type and suggest a basic build pipeline configuration. You can customize this YAML file to include specific build steps, unit tests, and deployment tasks.

For example, a simple Azure Pipelines YAML for a Node.js app might look like this:


trigger:
- main

pool:
  vmImage: 'ubuntu-latest'

steps:
- task: NodeTool@0
  inputs:
    versionSpec: '16.x'
  displayName: 'Install Node.js'

- script: |
    npm install
    npm run build
  displayName: 'npm install and build'

- task: AzureWebApp@1
  inputs:
    azureSubscription: ''
    appType: 'webAppLinux'
    appName: ''
    package: '$(System.DefaultWorkingDirectory)/build'
  displayName: 'Deploy to Azure App Service'
            

For GitHub Actions, the YAML would be placed in .github/workflows/.

3. Save and Deploy

After configuring your build pipeline, save the changes. Azure App Service will automatically trigger a build and deployment on the next commit to your selected branch.

Monitor Deployments

You can monitor the status of your builds and deployments in the "Deployment Center" or directly within Azure Pipelines/GitHub Actions.

Advanced CI/CD Scenarios

Resources

By implementing continuous integration, you streamline your development workflow and ensure your applications are always up-to-date and robust on Azure App Service.