Deploy a Web App to Azure

This tutorial guides you through the process of deploying a simple web application to Azure App Service.

Prerequisites

Before you begin, ensure you have the following:

Step 1: Create a Resource Group

A resource group is a logical container for Azure resources. All resources deployed in this tutorial will belong to this group.

az group create --name myResourceGroup --location eastus

Replace myResourceGroup with your desired name and eastus with your preferred Azure region.

Step 2: Create an App Service Plan

An App Service plan defines a set of compute resources for your web app to run on.

az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku B1 --is-linux

Step 3: Create a Web App

Now, create the actual web app that will host your application.

az webapp create --name mywebapp --resource-group myResourceGroup --plan myAppServicePlan --deployment-local-git

NOTE: Make sure your web app name is unique across all of Azure. Azure will append a unique identifier if your chosen name is not available.

Step 4: Deploy Your Application

Navigate to your web app's directory in your local terminal and deploy using Git.

cd /path/to/your/web/app
git init
git add .
git commit -m "Initial commit"
az webapp deployment source config-local-git --name mywebapp --resource-group myResourceGroup

The last command will output a Git remote URL. Add this remote to your local repository:

git remote add azure <output_from_previous_command>
git push azure master

Step 5: Verify Deployment

Once the push is complete, your web app should be live. You can access it using the URL generated in the previous step or by navigating to:

https://mywebapp.azurewebsites.net

Replace mywebapp with your web app's name.

Next Steps

Congratulations on deploying your first web app to Azure! Here are some suggestions for further exploration:

Explore Advanced Deployment Options