Deploy a web page from Cloud Shell
In this task you'll deploy code to a web app.
Deploying means copying your website's files to the web app. There are several ways: from Cloud Shell or your computer with the Azure CLI, from a ZIP file, or automatically from GitHub every time you change your code.
The quickest way to see it work is a ZIP deploy from Cloud Shell: you zip your files and send them to the app with az webapp deploy. The portal's Deployment Center is where you set up automatic deployment from GitHub.
Example. Ironbridge Payments keeps its status page in GitHub. Every time someone merges a change, GitHub Actions deploys it to the web app, so nobody copies files by hand.
Before you start
You need: Contributor on the resource group. Time: 10 minutes.
Where to look
- App Services
- app-practice
- Deployment Center
Steps
- Open Cloud Shell in Bash and make a folder with one page:Type
mkdir site && cd site, thenecho '<h1>Hello from Azure</h1>' > index.html - Zip the page:Type
zip site.zip index.html - Deploy the ZIP file to app-practice (your app's full name):Type
az webapp deploy --resource-group rg-portal-practice --name <app name> --src-path site.zip --type zip - app-practice is a Node app, which expects a Node program. Tell it to serve your files as they are:Type
az webapp config set --resource-group rg-portal-practice --name <app name> --startup-file "pm2 serve /home/site/wwwroot --no-daemon". The app restarts. - Open the app's Default domain link (give it a minute to restart). You'll see Hello from Azure.
- Change the page, zip it again and run the same
az webapp deploycommand. Refresh the browser to see the new version. - In the portal, open the app and select Deployment Center. It has Settings, Logs and FTPS credentials tabs. Under Source, look at the choices, grouped into Continuous Deployment (CI/CD) such as GitHub, and Manual Deployment (Push), but don't save anything.Connecting GitHub needs a GitHub account and creates a workflow file in your repository.
Commands
# Make a one-page site and zip it
mkdir site && cd site
echo '<h1>Hello from Azure</h1>' > index.html
zip site.zip index.html
# Deploy the ZIP file to an existing app
az webapp deploy --resource-group rg-portal-practice --name <app name> --src-path site.zip --type zip
# A Linux Node app needs this to serve plain HTML files
az webapp config set --resource-group rg-portal-practice --name <app name> \
--startup-file "pm2 serve /home/site/wwwroot --no-daemon"
Watch out for
- Cost
- Deploying is free. You're sending files to the app you already made, so nothing new is created or charged.
- Security
- Never deploy secrets, such as passwords or keys, inside your site's files. Use app settings or Key Vault (next task). New apps have basic authentication (publishing passwords) turned off, which is safer; the Azure CLI signs in with your Entra account instead.
- Common mistakes
- Zipping the folder instead of the files inside it, so index.html ends up one level too deep. Forgetting the startup command, so the Node app shows an error page instead of your page. Expecting a change to appear without deploying again. Older guides use
az webapp up: it still works but is being retired, and it can create its own plan, which isn't free unless you add--sku F1.
Clean up
- Resource groups
- rg-portal-practice
- Delete resource group
Keep the app for the next task. Remove the practice folder with cd ~ && rm -r site. At the end of this section, delete the resource group to remove the app and its plan.
Words to know
- Deployment Center
- The page where you connect a web app to GitHub, Azure Repos or another source.
- GitHub Actions
- GitHub's automation, which can build and deploy your code whenever it changes.
- ZIP deploy
- Uploading your site as one ZIP file, which App Service unpacks.
Tick off each step and track your progress in the guide.
Open this task in Azure Portal, Hands On