Azure Documentation

Azure CLI App Service Commands

This section details the Azure Command-Line Interface (CLI) commands for managing Azure App Service resources. Azure App Service is a cloud service for hosting web applications, REST APIs, and mobile back ends. The Azure CLI provides a set of commands to create, configure, and manage App Service resources.

Key Concepts

Before diving into commands, understand these core App Service concepts:

Common Commands

Creating an App Service

To create a new web app, you first need an App Service Plan. Here's how to create both:


# Create a resource group (if you don't have one already)
az group create --name myResourceGroup --location "East US"

# Create an App Service Plan (e.g., Free tier)
az appservice plan create --name myAppServicePlan --resource-group myResourceGroup --sku F1 --is-linux

# Create a web app within the plan
az webapp create --name myUniqueAppName --resource-group myResourceGroup --plan myAppServicePlan
            

Managing Web Apps

Here are some essential commands for managing your web apps:

Deployment Slots

Deployments slots allow for safe deployment and rollback.

Configuration and Settings

Manage application settings, connection strings, and more.

For a full list of commands and their options, use az webapp --help.

Deployment

The Azure CLI supports various deployment methods. Here's an example of deploying from a local Git repository:


# Enable local Git deployment
az webapp deployment source config-local-git --name myUniqueAppName --resource-group myResourceGroup

# The command output will provide Git remote URL. Add it to your local Git repo:
# git remote add azure 

# Then push your code
# git push azure master
            
Ensure you have the Azure CLI installed and logged in with az login before executing these commands.

Refer to the official Azure documentation for more detailed guides and advanced scenarios.