Azure App Service0.3.1Minimum Jenkins requirement: 1.651.3ID: azure-app-service
A Jenkins plugin to deploy an Azure App Service (currently supports only Web App).
How to Install
You can install/update this plugin in Jenkins update center (Manage Jenkins -> Manage Plugins, search Azure App Service Plugin).
You can also manually install the plugin if you want to try the latest feature before it's officially released. To manually install the plugin:
- Clone the repo and build:
- Open your Jenkins dashboard, go to Manage Jenkins -> Manage Plugins.
- Go to Advanced tab, under Upload Plugin section, click Choose File.
targetfolder of your repo, click Upload.
- Restart your Jenkins instance after install is completed.
Deploy to Azure Web App
To use this plugin to deploy to Azure Web App, first you need to have an Azure Service Principal in your Jenkins instance.
- Create an Azure Service Principal through Azure CLI or Azure portal.
- Open Jenkins dashboard, go to Credentials, add a new Microsoft Azure Service Principal with the credential information you just created.
Deploy to Web App through File Upload
You can deploy your project to Azure Web App by uploading your build artifacts (for example,
.war file in Java) using Git or WAR deploy.
- Create a new freestyle project in Jenkins, add necessary build steps to build your code.
- Add a post-build action 'Publish an Azure Web App'.
- Select your Azure credential in Azure Profile Configuration section.
- In App Configuration section, choose the resource group and web app in your subscription, and also fill in the files you want to deploy (for example, a war package if you're using Java).
- There are two optional parameters Source Directory and Target Directory that allows you to specify source and target folders when uploading files. For example, Java web app on Azure is actually running in a Tomcat server. So you should upload you war package to
webappsfolder. So in this case, set Target Directory to
- You can also set Slot Name if you want to deploy to a slot other than production.
- Save the project and build it, your web app will be deployed to Azure when build is completed.
Deploy to Web App on Linux using Docker
Web App on Linux supports a different way to do the deployment using Docker. To deploy using Docker, you need to provide a
Dockerfile that packages your web app with service runtime into a docker image. Then the plugin will build the image, push it to a docker registry and deploy the image to your web app.
Web App on Linux also supports traditional ways like Git and WAR deploy, but only for built-in languages (.NET Core, Java, Node.js, PHP and Ruby). For other languages, you need to package your application code and service runtime together into a docker image and use docker to deploy.
To deploy using docker:
- Same as #1 - #3 of file upload approach.
- Select a Linux web app, choose Publish via Docker.
- Fill in Dockerfile path (by default it's
**/Dockerfile), Docker registry URL (leave it empty if you use DockerHub), Registry credentials.
- Optionally you can specify the docker image name and tag in Advanced tab, by default image name is get from the image name you configured in Azure portal (in Docker Container setting) and tag is generated from
$BUILD_NUMBER. So please specify the image name in at least one place (in Docker Container settings in portal or Docker Image in advanced options).
- Please also be noted deployment will fail if you're used built-in docker image setting. So please first go to Docker Container setting in Azure portal to change docker config to use custom image. For built-in image, please use file upload approach to deploy.
- Similar to file upload approach, you can choose a different slot other than production.
- Save and build the project, you'll see your container image is pushed to your registry and web app is deployed.
Deploy using Pipeline
You can also use this plugin in pipeline (Jenkinsfile). Here are some samples to use the plugin in pipeline script:
To deploy a Java web app using file upload:
azureWebAppPublish azureCredentialsId: '<credential_id>', resourceGroup: '<resource_group_name>', appName: '<app_name>', filePath: '*.war', sourceDirectory: 'target', targetDirectory: 'webapps'
To deploy using docker:
azureWebAppPublish azureCredentialsId: '<credential_id>', publishType: 'docker', resourceGroup: '<resource_group_name>', appName: '<app_name>', dockerImageName: '<image_name>', dockerImageTag: '<image_tag>', dockerRegistryEndpoint: [credentialsId: '<registry_credential_id>', url: "<registry_url>"]
For advanced options, you can use Jenkins Pipeline Syntax tool to generate a sample script.
Azure App Service Plugin collects usage data and sends it to Microsoft to help improve our products and services. Read our privacy statement to learn more.
You can turn off usage data collection in Manage Jenkins -> Configure System -> Azure -> Help make Azure Jenkins plugins better by sending anonymous usage statistics to Azure Application Insights.
Version 0.3.1, 2018-05-30
- Switch to war deploy for Java apps
- Add null check for path names when deploy
Version 0.3.0, 2018-04-03
- Add an option to skip docker build step (#25)
- Restart slot after successful deployment (JENKINS-48191, #21)
- Support Java container app on Linux (#23)
- Support for credentials lookup in Folders
- Expands variables in source/target directory and slot name (#24)
Version 0.2.0, 2018-01-05
- Support MSI
Version 0.1.3, 2017-11-07
- Specify refspec explicitly when doing git push
- Add Third Party Notice
Version 0.1.2, 2017-10-18
- Remove runtime licenses
Version 0.1.1, 2017-09-30
Improve stability of FTP and Docker deploy
Version 0.1, 2017-07-18
- Initial release
- Support deploy to Azure Web App through Git and FTP
- Support deploy to Azure Web App on Linux through Docker