Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Latest commit

 

History

History
88 lines (60 loc) · 3.04 KB

deploy-to-azure-web-app-using-jenkins.md

File metadata and controls

88 lines (60 loc) · 3.04 KB

Deploy to Azure Web App for Containers using Jenkins

This tutorial shows you how to deploy this containerized app to Azure Web App for Containers using Azure App Service Plugin. Below are the major steps in this tutorial.

Create Azure Container Registry

  1. login your Azure CLI, and set your subscription id

    az login
    az account set -s <your-subscription-id>
  2. Run below command to create an Azure Container Registry. After creation, use login server as Container Registry URL in the next section.

    az acr create -n <your-registry-name> -g <your-resource-group-name> --sku <sku-name> --admin-enabled true
  3. Run below command to show your Azure Container Registry credentials. You will use Docker registry username and password in the next section.

    az acr credential show -n <your-registry-name>

Prepare Jenkins server

  1. Deploy a Jenkins Master on Azure

  2. Connect to the server with SSH and install the build tools:

    sudo apt-get install git maven docker.io
    
  3. Install the plugins in Jenkins. Click 'Manage Jenkins' -> 'Manage Plugins' -> 'Available', then search and install the following plugins: EnvInject, Azure App Service Plugin.

  4. Add a Credential in type "Microsoft Azure Service Principal" with your service principal.

  5. Add a Credential in type "Username with password" with your account of docker registry.

Create job

  1. Add a new job in type "Pipeline".

  2. Enable "Prepare an environment for the run", and put the following environment variables in "Properties Content":

    AZURE_CRED_ID=[your credential id of service principal]
    RES_GROUP=[your resource group of the web app]
    WEB_APP=[the name of the web app]
    ACR_SERVER=[your address of azure container registry]
    ACR_CRED_ID=[your credential id of ACR account]
    DOCUMENTDB_URI=[your documentdb uri]
    DOCUMENTDB_KEY=[your documentdb key]
    DOCUMENTDB_DBNAME=[your documentdb databasename]
    
  3. Choose "Pipeline script from SCM" in "Pipeline" -> "Definition".

  4. Fill in the SCM repo url and script path.

Build and Deploy Docker Container Image to Azure Web App for Containers

  1. Verify you can run your project successfully in your local environment. (Run project on local machine)

  2. Run jenkins job.

  3. Navigate to the website from your favorite browser. You will see this app successfully running on Azure Web App for Containers.

Clean Up Resources

Delete the Azure resources you just created by running below command:

az group delete -y --no-wait -n <your-resource-group-name>