Azure App Service: Quickstart Tutorial
This guide will walk you through the process of deploying your first web application to Azure App Service. App Service is a fully managed platform for building, deploying, and scaling web apps and APIs. You can use Node.js, .NET, Java, Python, PHP, or Ruby to build your apps.
Prerequisites
Before you begin, ensure you have the following:
- An Azure account. If you don't have one, you can sign up for a free trial.
- The Azure CLI installed on your local machine.
- A simple web application ready for deployment (e.g., a basic HTML page, a Node.js Express app, or a Python Flask app). For this tutorial, we'll assume you have a basic Node.js app.
Step 1: Create a Resource Group
Create a Resource Group
A resource group is a logical container for your Azure resources. It helps you manage related resources together.
Open your terminal or command prompt and run the following Azure CLI command:
az group create --name myResourceGroup --location eastus
This command creates a resource group named myResourceGroup in the eastus region.
Step 2: Create an App Service Plan
Create an App Service Plan
An App Service plan defines a set of compute resources for your web app to run on. It determines the location, size, and features of the web server farm.
Run the following command to create a new App Service plan:
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku F1 --is-linux
--name: A unique name for your App Service plan.--resource-group: The name of the resource group you created.--sku F1: Specifies the "Free" tier. For production workloads, consider higher tiers like B1, S1, P1v2, etc.--is-linux: Specifies that you want to use a Linux environment.
Step 3: Create a Web App
Create a Web App
Now, create the web app itself, linking it to the App Service plan.
Execute this command:
az webapp create --resource-group myResourceGroup --plan myAppServicePlan --name myuniqueappname --runtime "node:18-lts"
--name: A globally unique name for your web app. This will be part of the URL (e.g.,myuniqueappname.azurewebsites.net).--runtime: Specifies the runtime stack for your application. Replacenode:18-ltswith your desired runtime (e.g.,python:3.10,dotnet:7.0).
Step 4: Deploy Your Application
Deploy Your Application
For this quickstart, we'll use deployment from a local Git repository. Make sure your application code is in a local Git repository and committed.
First, enable local Git deployment for your web app:
az webapp deployment source config-local-git --name myuniqueappname --resource-group myResourceGroup
This command will output Git credentials. Add these as a remote to your local Git repository:
git remote add azure
Now, push your code to Azure:
git push azure master
You will be prompted for the Git username and password generated by the az webapp deployment command.
Step 5: Verify Your Deployment
Verify Your Deployment
Once the deployment is complete, you can access your web app by navigating to its URL in a web browser.
The URL will be in the format: http://myuniqueappname.azurewebsites.net
You should see your deployed web application!
Next Steps
Congratulations on deploying your first web app to Azure App Service!
- Explore other deployment methods like CI/CD pipelines, FTP, or VS Code extensions.
- Learn how to configure custom domains.
- Discover scaling options for your application.
- Secure your app with SSL/TLS certificates.