Deploying PHP Applications to Azure App Service with Azure DevOps
This post is about deploying PHP applications to Azure App Service with Azure DevOps. Recently I had to deploy PHP application to Azure App Service. You can deploy it to Azure App Service using FTP, since there is no compilation steps required. If you’re using Composer - Dependency Manager for PHP, you need to run the composer install before deploying the files to app service via FTP. Instead of using deploying FTP deploy the app, I choose to implement a deployment pipeline, so that I don’t want to share the FTP credentials to the developer. And if I enable continuous integration - when ever developer commit some changes, can be deployed automatically to the app service.
In the Azure DevOps I used a classic editor option to create the pipeline. Firstly I created a pipeline with empty job since there is no predefined task available for PHP deployment. In the tasks I added first Bash script task - for running the command -
composer install --no-interaction --prefer-dist. Next I added
Archive files task. In this task make sure, un select the
Prepend root folder name to archive paths option.
Next I am adding
Publish Artifact task, so that I can publish the Zip file from the directory to the artifacts location. And finally I am adding Azure App Service deployment task. In the task you need to select the
Package or folder as the
$(Build.ArtifactStagingDirectory)/**/*.zip file - which the output of the Publish Artifact Task.
And you need to choose the Runtime Stack - 7.4 - the PHP runtime you would like to use. And here is the complete build pipeline.
And here is the YAML - Exported from Azure DevOps.
Here few helpful links which talks about deploying PHP apps to Azure App Service.
Happy Programming :)