Azure Documentation

Your guide to building and deploying with Microsoft Azure.

Tutorial: Set Up a Web App on Azure

This tutorial guides you through the process of creating and configuring your first web application hosted on Microsoft Azure.

Prerequisites

Step 1: Create a Web App Resource

Using the Azure Portal

  1. Sign in to the Azure portal.
  2. In the top search bar, type "App Services" and select it from the list.
  3. Click the + Create button.
  4. On the "Basics" tab:
    • Subscription: Select your Azure subscription.
    • Resource group: Click "Create new" and give it a name (e.g., myWebAppRG).
    • Name: Enter a unique name for your web app (e.g., my-awesome-web-app-123). This will be part of your URL.
    • Publish: Select "Code".
    • Runtime stack: Choose your preferred language and version (e.g., "Node 18 LTS", ".NET 7", "Python 3.10").
    • Operating System: Select "Linux" or "Windows".
    • Region: Choose a region closest to your users.
  5. Click Review + create.
  6. Once validation passes, click Create.

Using Azure CLI

Open your terminal or command prompt and run the following commands:

# Log in to Azure
az login

# Create a resource group
az group create --name myWebAppRG --location eastus

# Create the web app
az webapp create --resource-group myWebAppRG --name my-awesome-web-app-cli --runtime "NODE|18-lts" --deployment-local-git

Replace my-awesome-web-app-cli with your desired web app name and adjust the --runtime as needed.

Step 2: Deploy Your Application Code

Once your web app resource is created, you need to deploy your code. Here are common methods:

For this tutorial, let's assume you're using Local Git Deployment. After creating the web app with --deployment-local-git, you will be provided with a Git URL. You can then clone it and push your code.

For more detailed deployment options, refer to the App Service Deployment Guide.

Step 3: Configure Your Web App

Navigate to your web app in the Azure portal. You can find options for:

Example: Adding an Application Setting

  1. Go to your App Service in the Azure portal.
  2. In the left-hand menu, under "Settings", select Configuration.
  3. Go to the "Application settings" tab.
  4. Click + New application setting.
  5. Enter a Name (e.g., MY_API_KEY) and a Value (e.g., yourSecretKey123).
  6. Click OK and then Save at the top of the Configuration blade.

Step 4: Browse Your Web App

You can find the URL of your web app on its Overview page in the Azure portal. It will look something like https://your-app-name.azurewebsites.net.

Open this URL in your web browser to see your deployed application!

Next Steps