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
Create a web app
- From Azure portal > App Services > + Add
- 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
- Open the Releases tab of the Build & Release hub, open the + drop-down in the list of release definitions, and choose Create release definition
- In the DEPLOYMENT TEMPLATES dialog, select the “Deploy PHP App to Azure App Service” template and choose OK.
- Click “Choose Later” for the artifact to be deployed.
- 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
- Click on “Link to an artifact source”
- Select the Github as the artifact source type and point it to your Github repository (forked earlier). You may need to create GitHub endpoint
- 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.
- Take App Offline: If you run into locked file problems when you test the release, try selecting this check box.
- 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”.
- Save the new release definition. Create a new release and verify that the application has been deployed correctly.