Learn to build and deploy with confidence.
Azure App Service is a fully managed platform for building, deploying, and scaling web apps and APIs. This tutorial will guide you through the process of deploying a sample application to Azure App Service using common deployment methods.
You can create an App Service instance through the Azure portal, Azure CLI, or other tools. We'll use the Azure CLI for this example.
Open your terminal or Azure Cloud Shell and run the following commands:
# Log in to your Azure account
az login
# Set your subscription (replace with your actual subscription ID)
az account set --subscription "YOUR_SUBSCRIPTION_ID"
# Create a resource group (if you don't have one already)
az group create --name MyResourceGroup --location "East US"
# Create an App Service Plan (defines the underlying compute resources)
# Using F1 (Free) tier for demonstration. For production, choose a suitable tier.
az appservice plan create --name MyAppServicePlan --resource-group MyResourceGroup --sku F1 --is-linux
# Create the Web App
az webapp create --name MyUniqueWebAppName --resource-group MyResourceGroup --plan MyAppServicePlan --runtime "DOTNETCORE:6.0"
# Note: Replace "DOTNETCORE:6.0" with your desired runtime, e.g., "NODE:18-lts", "PYTHON:3.9", "PHP:8.1"
Remember to replace MyUniqueWebAppName
with a globally unique name for your web app. If the name is taken, you'll need to choose another one.
Azure App Service supports various deployment methods, including:
For this tutorial, we'll focus on Local Git and GitHub integration.
This method is straightforward for quick deployments.
You need to set deployment credentials for your App Service. You can use user-level credentials or scm-user credentials. User-level credentials apply to all apps in your subscription.
# Set user-level deployment credentials (choose a username and password)
az webapp deployment user set --user-name --password
Important: Save these credentials securely. They are used for all Git-based deployments to your App Service.
Navigate to your application's root directory in your local terminal.
# Initialize a Git repository if you haven't already
git init
# Add your application files
git add .
git commit -m "Initial commit"
# Add Azure App Service as a remote repository
# Replace MyUniqueWebAppName with your actual web app name
git remote add azure https://<your_username>:<your_password>@myuniquewebappname.scm.azurewebsites.net:443/MyUniqueWebAppName.git
You'll be prompted for the username and password you set in the previous step.
Now, push your code to the Azure remote. This deploys your application.
git push azure master
If your default branch is not master
, use its name instead (e.g., main
).
This method sets up a pipeline where changes pushed to your GitHub repository automatically trigger a deployment to Azure App Service.
Azure will set up a GitHub Actions workflow (or a similar CI/CD pipeline) that monitors your chosen branch. Pushing new commits to that branch will automatically redeploy your application.
Once the deployment is complete, you can access your web application by navigating to its URL. This will be in the format: https://MyUniqueWebAppName.azurewebsites.net
.
You can also monitor deployment logs and application health from the Deployment Center and App Service logs sections in the Azure portal.
package.json
for Node.js, requirements.txt
for Python).You have successfully deployed an application to Azure App Service! Azure App Service offers numerous features for managing your applications, including custom domains, SSL certificates, autoscaling, and integrated monitoring. Explore the Azure portal to discover these capabilities.