Getting Started with App Services

Welcome to the App Services documentation! This guide will walk you through the essential steps to get your first application running on App Services. Whether you're deploying a web application, an API, or a background task, this guide provides the foundational knowledge you need.

Prerequisites

Before you begin, ensure you have the following:

  • A Microsoft Azure account. If you don't have one, you can sign up for a free trial.
  • The Azure CLI installed and configured, or access to the Azure portal.
  • Your application code ready for deployment.

Step 1: Create an App Service

The first step is to create an App Service instance in Azure. This instance will host your application.

Using the Azure Portal

  1. Navigate to the Azure portal.
  2. Click on "Create a resource".
  3. Search for "Web App" and select it.
  4. Click "Create".
  5. Fill in the required details:
    • Subscription: Select your Azure subscription.
    • Resource Group: Create a new one or select an existing one.
    • Name: A globally unique name for your app.
    • Publish: Select your runtime stack (e.g., .NET, Node.js, Python, Java, Docker Container).
    • Operating System: Windows or Linux.
    • Region: Choose a region close to your users.
    • App Service Plan: Create a new one or select an existing one. This defines the compute resources for your app.
  6. Click "Review + create", then "Create".

Using the Azure CLI

You can also create an App Service using the Azure CLI. First, create a resource group if you don't have one:

az group create --name MyResourceGroup --location eastus

Then, create the App Service:

az appservice plan create --name MyPlan --resource-group MyResourceGroup --sku B1 --is-linux
az webapp create --resource-group MyResourceGroup --plan MyPlan --name myuniqueappname

Replace MyResourceGroup, MyPlan, and myuniqueappname with your desired names.

Step 2: Deploy Your Application

Once your App Service is created, you can deploy your application code. App Services supports various deployment methods:

Local Git Deployment

This is a common and straightforward method for many applications.

  1. Enable local Git deployment for your App Service in the Azure portal under "Deployment Center".
  2. Configure a deployment user.
  3. Clone the Git repository provided by Azure.
  4. Add your application files to the repository, commit them, and push them to the remote Azure repository.

Container Deployment

If you're using Docker, you can deploy your container image.

  • Ensure your Docker image is built and pushed to a registry (like Azure Container Registry or Docker Hub).
  • In the Azure portal, navigate to your App Service, go to "Container settings", and configure it to pull from your registry.

Other Deployment Methods

App Services also integrates with:

  • GitHub Actions and Azure Pipelines for CI/CD.
  • FTP and WebDeploy.
  • Visual Studio and Visual Studio Code integrations.

Step 3: Configure Your App Service

After deployment, you might need to configure your App Service:

  • Application Settings: Set environment variables and connection strings for your application.
  • Connection Strings: Store database connection strings securely.
  • Custom Domains: Map your custom domain names to your App Service.
  • SSL Certificates: Secure your application with SSL/TLS certificates.
  • Startup Command: If your application requires a specific command to start, configure it here.

Important Note on Application Settings

Always use Application Settings or Connection Strings in Azure to store sensitive information like API keys and database credentials, rather than hardcoding them directly in your application's source code.

Step 4: Browse Your Application

Once deployment and configuration are complete, you can access your application through its default URL (e.g., http://your-app-name.azurewebsites.net) or your custom domain.

Tip

Explore the "Deployment Center" and "Diagnose and solve problems" sections in the Azure portal for more insights into your deployment and application health.

Next Steps

This guide covers the basics. For more advanced topics, explore the following: