Back in December, the Azure App Service team built the Deploy to Azure plugin which provided integration with Bitbucket and enabled publishing your Bitbucket repository to Azure App Service. Azure App Service is a cloud platform that enables developers to build powerful web and mobile apps that connect to data anywhere, in the cloud or on-premises.
With today’s announcement of Bitbucket Pipelines, a continuous delivery service built within Bitbucket Cloud, it is worth revisiting the deploy to Azure story and providing more details on how easy it is to publish to Azure App Service Web Apps using Bitbucket Pipelines. Atlassian provides the tools to help every team unleash their full potential with several popular products like JIRA, Bitbucket, Confluence, and HipChat. Bitbucket is a distributed version control system that makes it easy for you to collaborate with your team, and Bitbucket Pipelines is a new feature of Bitbucket to help teams build, test and deploy code on every push. Empower your team to achieve Continuous Delivery and help them deliver better software, faster. We’ve been playing with the Bitbucket Pipelines beta for some time, and we’ve outlined below a simple process for using Bitbucket Pipelines to deploy web applications to Azure App Service.
How to Deploy from Bitbucket Pipelines to Azure Web Apps
Setting up Bitbucket Pipelines to start utilizing CI/CD can be achieved with a few steps. The following diagram depicts one possible scenario for getting started.
A sample Bitbucket repository that has been created by following this process is available here. It provides a walkthrough with more detailed instructions.
In order to make the process of configuring Pipelines for deploying to Azure Web Apps a simple process, we’ve created an extension for Visual Studio Code, the cross-platform IDE (available for Windows, Linux, and OS X).
The Visual Studio Code Extension
The “Bitbucket Pipelines Deploy to Azure” Visual Studio Code extension is available today in Bitbucket for anyone to start using it to configure Bitbucket Pipelines for deploying to Azure Web Apps. The overview section of the extension’s repository provides documentation on the extension and how to install it. Once installed, the extension appears in the list of installed VS Code extensions:
The extension provides several commands, shown below, that can help accelerate getting started using Bitbucket Pipelines:
Of particular relevance to anyone that wants to start deploying immediately from Bitbucket to Azure Web Apps using Bitbucket Pipelines are the 2 topmost commands:
- Add Pipelines .yml to Deploy to Azure Web App (FTP)
- Add Pipelines .yml to Deploy to Azure Web App (Kudu)
Each one of those 2 commands, once picked, adds 3 files to your codebase:
- bitbucket-pipelines.yml: A sample YAML file configured to use the default Atlassian Docker image, perform any required prep work, and then call the associated bash script.
- deploy-to-azure.bash: A bash script that either uses the FTP service or the Azure Web App Kudu service to deploy your repository to the configured Azure Web App.
- deploy-to-azure.md: In order for the deployment process to work correctly, a few environment variables need to be created in your Bitbucket repository. This file documents all you need to know to get things setup.
In a nutshell, performing CI/CD between Bitbucket and Azure Web Apps can be very simple and efficient using Bitbucket Pipelines, and you can start doing that today!