Deploy a Web App with Azure CLI
Learn to deploy a web app using the Azure CLI in this hands-on Azure tutorial. Step-by-step commands, troubleshooting, and what to study next.
Focus: use azure cli to deploy a web app
You’ve built a web app that works perfectly on your laptop. But when you try to share it with the world, you freeze: how do you get it onto a real server without clicking through dozens of Azure portal screens? The Azure CLI is the answer — it turns a 20-minute point-and-click deployment into a few seconds of typed commands, and it unlocks repeatable, scriptable workflows that you’ll use every day as a developer or DevOps engineer. In this lesson, you’ll learn how to use Azure CLI to deploy a web app from zero to live, with commands you can copy, adapt, and even automate.
The problem this lesson solves
Manual deployments are a trap. Every time you fix a bug, you have to open the browser, log in, find the right resource group, upload your files, and hope you didn’t miss a setting. That process is slow, error-prone, and impossible to reproduce if you ever need to rebuild your infrastructure from scratch.
More importantly, manual work doesn’t scale. When you have multiple environments (dev, staging, production), or when you’re part of a team that ships weekly, you need a single source of truth for how your app gets deployed. The Azure CLI gives you that: every action you take in the portal is available as a command, and those commands can be saved in a script, triggered by a CI/CD pipeline, or run from your local machine.
What you’ll be able to do after this lesson:
- Create a resource group, App Service plan, and web app from the terminal
- Deploy your code using a local Git push
- Verify your deployment and view your live app
- Avoid the most common pitfalls that trip up beginners
Core concept / mental model
Think of Azure CLI as your remote control for Azure. Instead of browsing through menus, you send commands to Azure’s API, and the CLI translates them into HTTP requests. Behind the scenes, it’s all REST — but you don’t need to know that to get value.
The mental model in three pieces:
- Resource Group – a container (like a folder) that holds all your related Azure resources. It’s a logical grouping for billing, permissions, and lifecycle management.
- App Service Plan – defines the compute resources (CPU, memory, scaling) your app will use. Think of it as the machine your app runs on.
- Web App – the actual application instance that runs your code and responds to HTTP requests. It’s the process that serves your site.
The magic of the CLI is that you can create all three with a few commands, and you can destroy them just as easily — perfect for testing and learning.
How it works step by step
The deployment flow follows a natural order: prepare → create → deploy → verify. Here’s what happens at each stage:
- Log in to Azure – you authenticate your terminal with your Azure account. The CLI stores a token so you don’t have to re-enter credentials for every command.
- Create a resource group – a unique name (like
my-app-rg) in a region near you. This keeps all your resources organized and easy to clean up later. - Create an App Service plan – choose a tier (Free, Basic, Standard) based on your needs. For learning, the Free tier is perfect because it costs nothing.
- Create the web app – specify a globally unique name (like
my-unique-app-2024) and a runtime stack (e.g., Node.js 18 LTS or Python 3.12). The CLI provisions the app and gives you a public URL likehttps://my-unique-app-2024.azurewebsites.net. - Deploy your code – you push your code from a local Git repository to the App Service’s built-in Git endpoint. Azure automatically builds and runs your app.
- Verify – open the URL in your browser or use
curlto confirm it’s live.
Each step depends on the previous one, so follow the order strictly. If you skip ahead, you’ll get errors like resource not found or invalid operation.
Hands-on walkthrough
Let’s deploy a simple web app. We’ll use a “Hello World” Node.js app, but the same steps work for Python, .NET, or any supported runtime.
Prerequisites
- Azure account – if you don’t have one, create a free account (you get $200 credit and 12 months of popular services free).
- Azure CLI – install it from the official docs or use the cloud shell (cli.azure.com).
- Git – for your local Git push.
Step 1: Log in to Azure
Run the following command in your terminal. It will open a browser window and ask you to log in with your Microsoft account.
az login
You should see a list of subscriptions. If you have only one, that’s fine. If you have multiple, set the one you want to use:
az account set --subscription "Your Subscription Name"
Step 2: Create a resource group
Choose a name and a region. Use eastus or westeurope for low latency in your area.
az group create --name my-app-rg --location eastus
Expected output:
{
"id": "/subscriptions/...",
"location": "eastus",
"name": "my-app-rg",
"type": "Microsoft.Resources/resourceGroups"
}
Step 3: Create an App Service plan
For this tutorial, use the Free tier (F1) — it costs nothing. The --sku F1 flag sets it.
az appservice plan create --name my-app-plan --resource-group my-app-rg --sku F1 --is-linux
Note: The
--is-linuxflag is required if you are deploying a Linux-based container (e.g., Node.js). For Windows, omit it. This is a common mistake that causes a “runtime stack not found” error.
Step 4: Create the web app
The web app name must be globally unique — think of it as your subdomain. It can contain only letters, numbers, and hyphens.
az webapp create --name my-unique-app-2024 --resource-group my-app-rg --plan my-app-plan --runtime "NODE|18-lts"
For Python, use --runtime "PYTHON|3.12". For .NET, use --runtime "DOTNET|8.0". The list of supported runtimes is available with az webapp list-runtimes.
Expected output:
{
"name": "my-unique-app-2024",
"state": "Running",
"defaultHostName": "my-unique-app-2024.azurewebsites.net",
...
}
Step 5: Deploy your code with Git
First, set up a local Git repository for your app (if you haven’t already). Make sure your app has a package.json that works when Azure runs npm install and npm start.
cd my-app
az webapp deployment source config-local-git --name my-unique-app-2024 --resource-group my-app-rg
This command outputs a Git URL, like https://my-unique-app-2024.scm.azurewebsites.net/my-unique-app-2024.git. Add it as a remote:
git remote add azure <the-url-from-output>
Now push your code:
git add .
git commit -m "Initial commit"
git push azure master
Azure will receive the push and automatically build and deploy your app. The first push might take a couple of minutes.
Step 6: Verify your deployment
Open your URL in a browser, or use curl from the terminal:
curl https://my-unique-app-2024.azurewebsites.net
If you see Hello World (or your app’s content), congratulations — you’ve successfully deployed a web app using Azure CLI!
Compare options / when to choose what
You now know how to deploy with Azure CLI, but it’s not the only way. Here’s how the CLI compares to the Azure portal and other common tools:
| Method | Pros | Cons | Best when |
|---|---|---|---|
| Azure Portal | Visual, discoverable, good for beginners | Slow, error-prone for repeatable tasks, not scriptable | Exploring Azure, one-off setup |
| Azure CLI | Fast, scriptable, repeatable, easy to version-control | Requires learning commands, initial setup | Any serious deployment, CI/CD, multiple environments |
| GitHub Actions | Fully automated, integrated with repo, no manual step | More setup, a bit harder to debug | Team projects, continuous delivery |
| Azure DevOps Pipelines | Similar to GitHub Actions, tight Azure integration | Another tool to learn | Enterprise projects already using Azure DevOps |
When to choose what:
- Use the CLI when you need to deploy now and you want to learn the essentials.
- Use GitHub Actions when you want every push to main to deploy automatically.
- Use the Portal when you’re prototyping and want visual feedback.
Troubleshooting & edge cases
Even with the CLI, things can go wrong. Here are the most common errors and how to fix them:
Error: The parameter --is-linux cannot be used with a Windows plan.
You included --is-linux but your plan was created without it (or vice versa). Make sure the plan and web app are consistent: Linux plan → --is-linux flag; Windows plan → no flag.
Error: Webapp name not available
The name you chose is taken. Azure web app names are globally unique. Try a different combination, like my-unique-app-2024-abc.
Error: Resource group not found
You forgot to create the resource group first, or you misspelled it. Run az group list to see your groups.
Deployment succeeded but app shows “Service Unavailable”
This often means your app’s startup command is wrong. For Node.js, Azure expects a script named start in package.json. For Python, ensure your startup.txt or wsgi.py is accurate. Use the logs:
az webapp log tail --name my-unique-app-2024 --resource-group my-app-rg
Check the logs for the actual error.
az login opens browser but nothing happens
On some systems, the CLI can’t open a browser. Use device authentication:
az login --use-device-code
It will show a code you can enter at microsoft.com/devicelogin.
Common pitfalls to avoid
- Forgetting
--is-linuxwhen using a Linux runtime. - Using the same name for web app and resource group — they have different naming rules.
- Not checking your runtime version — Azure supports specific versions; always verify with
az webapp list-runtimes. - Pushing to
mastervsmain— Azure’s local Git default branch ismaster. If your local default ismain, usegit push azure main:masteror set it accordingly.
What you learned & what's next
You now have a repeatable, scriptable way to deploy a web app to Azure: you created a resource group, an App Service plan, a web app, and pushed your code with Git — all from the command line. You can explain the core idea behind using the Azure CLI to deploy a web app, and you’ve completed a practical exercise that proves it works.
This is the foundation for automating your entire Azure workflow. Next, learn how to set up continuous deployment with GitHub Actions, so every code push triggers a new deployment automatically. You’ll also benefit from understanding App Service configuration (environment variables, custom domains) and how to scale your plan when your app outgrows the free tier.
You’re one step closer to shipping confidently — and the terminal is your best friend. See you in the next lesson!
Practice recap
Create a new Azure web app and deploy a simple static HTML page using the Azure CLI. Modify your index.html, commit, and push again to see the update go live. Then delete the resource group with az group delete --name my-app-rg --yes to avoid any charges — you’ve just mastered the full lifecycle.
Common mistakes
- Forgetting the
--is-linuxflag when creating a Linux-based plan — your web app creation will fail with a runtime compatibility error. - Choosing a web app name that’s already taken — Azure names are globally unique, so you need to keep trying variants until one is available.
- Pushing to the wrong Git branch — Azure’s local Git expects
masterby default, so if your local default ismain, usegit push azure main:master. - Skipping the resource group creation — subsequent commands will fail with 'Resource group not found' unless you create it first.
- Not checking the runtime version — Azure only supports specific runtimes, so verify with
az webapp list-runtimesbefore creating the app.
Variations
- Use
az webapp createwith container support — deploy a Docker image via--deployment-container-image-nameinstead of pushing source code. - Deploy from a local ZIP archive using
az webapp deploy— faster for static sites or when you don't want to set up Git. - Script the whole flow in a shell script or CI pipeline — combine all commands with error handling for a zero-click deployment.
Real-world use cases
- A developer manually deploys a staging environment for a new feature branch by running a few Azure CLI commands before sharing the URL with the team.
- A DevOps engineer scripts the creation of a full production infrastructure (resource group, plan, web app) for a new client project in under five minutes.
- A CI/CD pipeline uses Azure CLI to deploy an updated Node.js backend to an existing web app after every successful merge to the main branch.
Key takeaways
- Azure CLI turns 20 minutes of portal clicking into a few seconds of scriptable commands — learn it early.
- Remember the order: login → resource group → plan → web app → deploy → verify; each step depends on the previous.
- The Free (F1) tier is perfect for learning — it costs nothing and supports all the same deployment flows.
- Web app names are globally unique — plan ahead or be ready to try alternatives.
- Consistent flags matter:
--is-linuxfor Linux runtimes, and correct runtime strings (NODE|18-lts,PYTHON|3.12, etc.). - Use
az webapp log tailto debug a deployed app that isn’t working — it’s your best friend.
Keep learning
Related tutorials, quizzes, and articles for this topic.
Discussion
Questions, corrections, and tips help everyone reading this page.
0 comments
Add a comment
No comments yet — start the thread.