22 C
Dubai
Sunday, December 22, 2024

Azure DevOps — Create CI/CD Pipeline for PHP Web App

1. Developers pull remote repository on local machine and apply latest changes
2. Commit code and push to Azure repository develop branch
3. The latest changes are reviewed and merged to Azure repository main or master branch
4. Automatically trigger the build and deploy web app on Azure app service

Step 1: Creating the PHP Web app and Test Locally.

Step 2: Configure Azure App Service.

Login into https://portal.azure.com

Step 3: Create the Azure DevOps Project and connect to the App service instance.

Login into https://dev.azure.com/ and create a new project

Setting up a Service Connection

To connect to the App Service from DevOps, we will need to first setup a service connection. Start by opening up DevOps, and select “Project Settings”.

In the Pipelines section, select “Service Connections” and hit the “Create service connection” button.

We will select “Azure Resource Manager” as the type, and hit next

Keep “Service Principle (automatic)” as the Authentication method.

Keep “Subscription” as the scope and make sure the correct one is selected. Then make sure to choose the same Resource Group that you created for the App Service above. We will also need to create and note a “Service Connection Name” that you will be using in the pipeline next. After you are finished, hit “Save” to create your service connection.

Click on repos to copy the Git credentials on a notepad.

Push from the local to remote repository using the below git commands on Git bash.

 git init
git add .
git commit -m ‘initial commit’
git push 

This brings a prompt, login into your Azure DevOps portal then this shows that the App has been push to the Azure repo.

Step 4: Create a Build Pipeline.

To connect the pipeline to the App service instance created.

1.Create pipeline.

2.Choose Azure repose (YAML)

Select PHP as Linux Web App on Azure to configure your pipeline.

The YAML file configuration triggers the pipeline to run whenever there is any update in the main branch of the repository. It builds and releases the code without having to make separate release pipeline. The stages will show that the code has been archived and deployed and the changes can be verified by reloading app service URL.

Local Browser

                                             Key notes

composer. Json files is important to set upbuild. otherwise, it is failed to build job.

{
    "require": {
        "nesbot/carbon": "2.53.*"
    }
}

Premnath
Premnath
I have been working as Cloud engineer in System Administration field in Microsoft Azure, Microsoft Office 365 / Exchange Servers / Endpoint Manager / Azure Active Directory (IAM) / PowerShell

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?