Deploy PHP application to Azure App Service using VSTS

This blog post shows how you can deploy a new PHP application from Visual Studio Team Services or Microsoft Team Foundation Server to Azure App Service.

Download the sample

  • Fork the Hello World sample app repository to your github account
    https://github.com/RoopeshNair/php-docs-hello-world

Create a web app

  • From Azure portal > App Services > + Add
    addazureappservice
  • Select Web Apps > Click “Create” with App Name, Subscription and Resource Group details. Once the deployment is successful, configure the PHP version in the “Application settings” to use “7.0” as shown below

createnewwebapp-1

Setup Release

  1. Open the Releases tab of the Build & Release hub, open the + drop-down in the list of release definitions, and choose Create release definition
  2. In the DEPLOYMENT TEMPLATES dialog, select the “Deploy PHP App to Azure App Service” template and choose OK.

deployphptemplate

  1. Click “Choose Later” for the artifact to be deployed.

chooselater

  1. Configure the Azure App Service Deployment task:
      • Azure Subscription: Select a connection from the list under Available Azure Service Connections. If no connections appear, choose Manage, select New Service Endpoint | Azure Resource Manager, and follow the prompts. Then return to your release definition, refresh the Azure Subscription list, and select the connection you just created.
        Note: If your Azure subscription is defined in an Azure Government Cloud, ensure your deployment process meets the relevant compliance requirements. For more details, see Azure Government Cloud deployments.
      • App Service Name: the name of the App Service (the part of the URL without .azurewebsites.net)
      • Deploy to Slot: make sure this is cleared (the default)
      • Virtual Application : leave blank
      • Package or Folder: Click on “…” button
        packageorfolder
      • Click on “Link to an artifact source”

linkartifactsource

      • Select the Github as the artifact source type and point it to your Github repository (forked earlier). You may need to create GitHub endpoint

githubartifact

      • Select the repo root as the folder to deploy
        selectedpackage
      • Advanced:(optional)
        • Deployment script: The task gives you additional flexibility to run deployment script on the Azure App Service. For example, you can run a script to update dependencies (example composer extension) on the Azure App Service instead of packaging the dependencies in the build step.
          composerextension
        • Take App Offline: If you run into locked file problems when you test the release, try selecting this check box.
    1. Type a name for the new release definition and, optionally, change the name of the environment from Default Environment to QA. Also, set the deployment condition on the environment to “Automatically start after release creation”.
    2. Save the new release definition. Create a new release and verify that the application has been deployed correctly.

    Related Topics

    1. Configure PHP in Azure App Service Web Apps
    1