Same as GCP and AWS, Azure also has a extremely convenient service to deploy an application called App Services. In this article, we will discuss how to deploy a web application using App Services. Also, we can deploy the code to the staging deployment slot.
Create a Web Application
Go to App Services and click “Add”.
We choose a resource group, you can create a new one if you do not have any resource group before. Give it a unique name and select PHP7.4, and choose Windows then click Review + create.
Click Create one more time.
Click Go to resource.
Then we go to Deployment slots under Deployment, and click upgrade.
Select Production and select the default pricing tiers, click Apply. Be friendly reminded that you do not really need to pay money if you are still trial, you had some credits already.
We click “Add Slot” first, then type staging as the name, click add.
Configure Web App Deployment
Click into the staging.
In Deployment Center, we select Local Git then click Continue.
Select the first one then continue.
We mark down this Git Url in notepad or something where.
Then we click Deployment Credentials, select user credentials. Type your own username and password and save.
Open CloudShell and select PowerShell.
Type below command to download our prepared file, and push to the App Service:
git clone https://github.com/manbobo2002/simple-php.git Set-Location -Path $HOME/simple-php git remote add [your_deployment_user_name] [git_clone_url] git push [your_deployment_user_name] master
Go back to Overview, and click Browse.
We are able to see our application now.
Swap the Staging
Back to our main panel, then choose deployment slots. Click Swap and choose source as our staging while destination is production. Then click Swap.
After swapping, we can see the same page as staging.
Back to CloudShell, run below command:
Get-AzResourceGroup -Name '[your-resource-group]*' | Remove-AzResourceGroup -Force -AsJob