What is Azure Web App? Create an Azure Web App
An Azure Web App is a specific type of resource under Azure App Service, used to host web applications and APIs in a fully managed environment without worrying about the underlying infrastructure.
What is an Azure Web App?
It's a managed hosting environment for running your website or API code, supporting multiple languages and frameworks, with built-in scaling, monitoring, and deployment tools.
Step 1: Create a Resource Group
az group create --name myResourceGroup --location eastus
Step 2: Create an App Service Plan
az appservice plan create \
--name myAppServicePlan \
--resource-group myResourceGroup \
--sku B1 --is-linux
Step 3: Create the Web App
az webapp create \
--resource-group myResourceGroup \
--plan myAppServicePlan \
--name myuniquewebappname \
--runtime "NODE:18-lts"
Step 4: Deploy Your Code
az webapp deployment source config-zip \
--resource-group myResourceGroup \
--name myuniquewebappname \
--src myapp.zip
Step 5: Browse Your Web App
az webapp browse --name myuniquewebappname --resource-group myResourceGroup
Common Use Cases
- Hosting company websites, portals, or internal tools
- Deploying REST APIs consumed by mobile or single-page applications
- Running staging and production environments using deployment slots
Ready to master Microsoft Azure?
Join Microsoft Azure Training Course at Uncodemy and learn with hands-on projects and mentor support.
Configuring the App After It Is Created
A new web app runs with default settings. Most real projects then need configuration, logs and the right runtime.
# See which runtime stacks are currently available
az webapp list-runtimes --os linux
# Add environment variables (read by your code as normal env vars)
az webapp config appsettings set \
--resource-group myResourceGroup \
--name myuniquewebappname \
--settings NODE_ENV=production API_BASE_URL=https://api.example.com
# Stream live logs while you test
az webapp log config --resource-group myResourceGroup \
--name myuniquewebappname --docker-container-logging filesystem
az webapp log tail --resource-group myResourceGroup --name myuniquewebappname
Runtime versions change over time, so always pick from the list command rather than copying an older version string from a tutorial. App settings are injected as environment variables and are not stored in your code, which keeps configuration separate per environment.
Releasing Safely with Deployment Slots
A slot is a second live copy of your app with its own hostname. The release flow usually looks like this:
- Create a staging slot.
- Deploy the new version to staging, not to production.
- Test the staging URL, including smoke tests from your pipeline.
- Swap staging and production. Azure warms up the new version before switching traffic.
- If something goes wrong, swap again to roll back.
az webapp deployment slot create --resource-group myResourceGroup \
--name myuniquewebappname --slot staging
az webapp deployment source config-zip --resource-group myResourceGroup \
--name myuniquewebappname --slot staging --src myapp.zip
az webapp deployment slot swap --resource-group myResourceGroup \
--name myuniquewebappname --slot staging --target-slot production
Slots are only available on some App Service plan tiers, so check that your plan supports them first. Settings marked as "deployment slot settings" stay with their slot during a swap, which is useful for connection strings that differ between staging and production.
Scaling, Identity and Security Basics
- Scale up by moving the plan to a larger tier when a single instance needs more CPU or memory.
- Scale out by adding instances, manually or with autoscale rules based on metrics such as CPU usage.
- Managed identity lets the app read secrets from Key Vault or connect to databases without storing passwords:
az webapp identity assign --resource-group myResourceGroup --name myuniquewebappname. - HTTPS only should be switched on, and a custom domain can be added with a managed or uploaded certificate.
- Access restrictions can limit an internal tool to known IP ranges or a virtual network.
Problems New Users Often Hit
| Symptom | Likely cause |
|---|---|
| Name already taken | The app name forms a public hostname, so it must be globally unique |
| Application error page after deploy | The app listens on a fixed port instead of the port Azure provides in the PORT variable |
| Missing dependencies | Build automation was not enabled, so packages were never installed |
| Config changes not visible | The app caches settings; restart it after changing them |
| Unexpected charges | Test plans left running; delete the resource group when finished |
A quick health habit: after every deployment, open the site, check the log stream for errors and confirm the expected version is running.