Home / Deploy PHP application to Azure App Service using Azure Pipelines


Azure Pipelines helps you set up a highly customizable continuous integration (CI) and continuous delivery (CD) pipeline to target app services, virtual machines, or containers in Azure whether you are developing a .NET, Java, Node, PHP, or a Python app.

In this lab, you will configure Azure Pipelines for a PHP app to deploy on to an Azure Web App.


Upon completion of this lab, you will be able to:

  • Set up a PHP Azure DevOps Project with Azure DevOps Demo Generator
  • Set up an Azure CI Pipeline
  • Set up an Azure Web App within the Release pipeline and deploy the PHP Application to the Azure Web App

Before you begin

  1. Refer Getting Started before you follow the lab exercises.

Exercise 1: Create a PHP application project using the Azure DevOps Demo Generator

In this practice lab, you are going to work on a PHP project. The purpose is to create a system for the developer to understand the list of tasks that are triggered once the code is pushed to a shared repository.

While the code is a simple PHP application, you will use Azure Command Line Interface(CLI) to provision the infrastructure to deploy the build artifacts.

  1. Use the Azure DevOps Demo Generator to provision project on your Azure DevOps Organization. This URL will automatically select the PHP template in the demo generator.

Exercise 2: Commit code changes which triggers a CI build

The Azure DevOps Demo Generator creates a Git repository with code in your Azure DevOps Organization. You are going to update the code and commit changes.

  1. Navigate to Repos tab in the Azure DevOps portal and navigate to the below path to edit the file.



  2. Scroll down to line number 11, select Edit , modify PHP to DevOps for PHP using Azure DevOps and choose Commit to save the changes to the code.


  3. Go to Builds tab under Pipelines. You should now see a build is in progress. The changes you just made are automatically built which will be deployed via the Release pipeline. Click the ellipsis to View build results.



Examine the Build Definition

Let’s explore the build definition. The tasks used in the build definition are listed below.

Build Definition

Tasks Usage
Archive files Since PHP is an interpreted language, there is no need to compile the code. Instead, the code is archived into a Zip file.
Publish Build Artifacts Publish the build artifacts so that it is available to the Release pipeline

Exercise 3: Configure the Release Definition

Once the build is complete, let us configure the CD pipeline. You will notice a release definition by navigating to Releases under the Pipelines section. The release will provision an Azure Web app using the Azure CLI and deploy the zip file to the Web App generated by the associated build.

  1. Under the Releases under Pipelines tab, select release definition PHP and click on Edit.


  2. Go to Tasks and select Dev environment.


  3. Select the Azure CLI task, choose the Azure subscription. There are 2 ways of choosing the Azure subscription.

    • If your subscription is not listed or if you want to use an existing service principal, click the Manage link.

      1. Click on the +New Service Connection button and select the Azure Resource Manager option. Provide Connection name, select the Azure Subscription from the list and then click on the Ok button. The Azure credentials will be required to authorize the connection.


    • If the subscription is already listed, select the Azure subscription from the list and click Authorize.


  4. Azure CLI is used in the inline script to create the following in Azure -

    • Resource Group
    • App Service Plan
    • App Service

    Deployment Location

  5. The variables are defined in the Variables section.


  6. Select the Azure App Service Deploy task and pick Azure subscription from the dropdown list, then click on Save.

    Deployment Slot

    Tasks Usage
    Azure CLI Executes the inline batch scripts to provision a Web App within a resource group
    Azure App Service Deploy Deploys the PHP code to the provisioned App service
  7. Queue the saved release definition to deploy the latest build artifacts to the Azure Web App.


    Create Release

  8. Once the release succeeds, navigate to the created Web App to view the PHP application.

    PHP App


In this lab, you have learnt how to deploy a PHP application on Azure Web App with Azure Pipelines.