Introduction
As businesses modernize their IT infrastructure, hosting web applications in the cloud has become a key strategy for improving scalability, reliability, and cost efficiency. Many organizations still rely on on-premises servers to host their company websites, but these setups often come with high maintenance costs, limited scalability, and hardware refresh challenges.
To eliminate the burden of physical infrastructure, companies are increasingly adopting Azure App Service a fully managed Platform as a Service (PaaS) solution for hosting web applications built on popular runtime stacks like .NET, Java, Python, Node.js, and PHP.
In this hands-on lab, you’ll learn how to:
- Create and configure an Azure Web App.
- Set up a deployment slot for staging and production environments.
- Configure continuous deployment using GitHub.
- Swap deployment slots for seamless updates.
- Implement autoscaling to ensure performance under variable loads.
By the end of this guide, you’ll understand how Azure Web Apps help teams deploy faster, scale smarter, and maintain high availability all without managing servers.
Skilling Objectives
You will learn how to:
- Deploy a PHP-based Azure Web App using App Service.
- Configure staging and production deployment slots for testing and release management.
- Automate deployments using a GitHub repository.
- Perform slot swaps to promote tested code into production.
- Configure autoscaling to automatically adjust resources based on demand.
Task 1: Create and Configure an Azure Web App
Why start here?
The Azure Web App is the foundational component of Azure App Service. It provides a managed environment to host your website code, manage scaling, and integrate DevOps pipelines — all without provisioning virtual machines.
Steps
Sign in to the Azure portal.
-
On the Basics tab, provide:
- Subscription: Your Azure subscription
- Resource group: Create or select an existing group
-
Web app name: A unique name (e.g.,
WebAppDemo123) - Publish: Code
- Runtime stack: PHP 8.2
- Operating system: Linux
- Region: East US
-
Pricing plan: Premium V3 (P1V3)
Once deployment completes, click Go to Resource to view your newly created Web App.

You now have a fully managed Azure Web App running PHP on Linux ready for configuration and deployment.
Task 2: Create and Configure a Deployment Slot
Why it matters
Deployment slots allow you to host multiple versions of your app within the same App Service plan. They are invaluable for staging, testing, and blue-green deployments without downtime.
Steps
From your Web App’s blade, open the Default domain link to confirm the app is running.


Return to the portal and navigate to Deployment slots under your Web App.
Click + Add Slot, name it
staging, and choose Do not clone settings.

Select Add. Once created, you’ll see both Production and Staging slots listed.

You now have a staging environment to test your app safely before releasing it to production.
Task 3: Configure Web App Deployment Settings
Why it matters
Continuous deployment ensures that your app service always reflects the latest tested code. By connecting your Web App to a GitHub repository, updates can be deployed automatically to your staging environment.
Steps
In the staging slot, select Deployment Center → Settings.
You notice an Error SCM basic authentication is disabled, click Enabled it.

Check the box for SCM basic Auth Publishing Credentials to enable

In the repository field, enter:
https://github.com/Azure-Samples/php-docs-hello-world
Go to Overview and open the Default domain link.
Verify the deployed app displays “Hello World!” confirming that deployment succeeded.

This setup enables automated updates from your GitHub repository to your staging environment.
Task 4: Swap Deployment Slots
Why it matters
Swapping deployment slots allows you to promote code that has been tested in staging directly into production with minimal risk and zero downtime. It’s an essential practice in modern DevOps workflows.
Steps
- Navigate back to Deployment slots in your Web App.
Once the swap completes, go back to your Web App Overview and open the production domain.
Verify that the production app now displays the “Hello World!” page.
Your previously tested staging code is now live in production — ensuring safe and seamless deployment.
Task 5: Configure and Test Autoscaling
Why it matters
Autoscaling ensures that your web app performs optimally under fluctuating traffic. Azure automatically adjusts the number of running instances based on real-time metrics like CPU usage or response time.
Steps
- In your App Service plan, go to Scale out (App Service plan).
- Select Automatic scaling mode.
To simulate load, navigate to Diagnose and solve problems → Load Test your App.

Create a new load test, assign a Unique name for the test (
webtest), Review and Create.

From the Overview | Create by adding HTTP requests, select Create.

On the Test plan tab, click Add request. In the URL field, paste in your Default domain URL. Ensure this is properly formatted and begins with https://. Select Add to save your changes.

Observe live metrics such as Virtual users, Response time, and Requests per second.

Stop the test once you verify that scaling is working correctly.
Autoscaling dynamically adjusts resources to maintain performance while optimizing cost — a key feature for production workloads.
Cleanup Your Resources
To avoid unnecessary costs, delete your lab resources after completion.
In the Azure portal:
- Go to your resource group.
- Select Delete resource group, enter the name, and confirm.
Conclusion
By completing this hands-on guide, you’ve implemented a full lifecycle workflow for deploying and managing web apps in Azure — from setup and deployment to autoscaling and cleanup.
Azure Web Apps simplifies application hosting by eliminating the need for physical infrastructure, offering built-in deployment pipelines, and supporting high availability and scalability out of the box.
Whether you’re migrating from on-premises servers or building new cloud-native applications, Azure App Service empowers your organization to innovate faster while keeping operations secure, scalable, and cost-effective.











Top comments (0)