# Azure Web App Deployment

Source: https://www.jawsdeploy.net/guides/azure-web-app-deployment

From an empty Azure App Service to a deployed release through a Jaws Deploy cloud target.

This guide walks through deploying to an Azure Web App through a Jaws Deploy cloud target. Prerequisites: an existing App Service in Azure, a service principal in the Azure tenant with at least Contributor on the App Service's resource group, and a packaged web app you want to deploy.

## 1. Connect your Azure subscription

In **Infrastructure -> Cloud accounts**, add an Azure account. Provide the tenant ID, subscription ID, service principal client ID, and client secret. The platform verifies the credentials and lists the App Services it can see.

## 2. Register the App Service as a target

Go to **Infrastructure -> Targets** and add an Azure Web App target. Pick the resource group and App Service from the dropdown (populated from the cloud account). Assign it to an environment - say, `Production` - and add a role tag like `role:web`.

## 3. Add a deployment step

In the project's deployment process, add a **Deploy to Azure Web App** step. Point it at the package and scope it to `role:web`. The step uses the Azure management API to upload the package and trigger an in-place deployment.

If you want zero-downtime, use deployment slots: deploy to a `staging` slot first, run smoke tests in a follow-up step, then swap slots.

## A small follow-up script step after the package deploy

Run it scoped to the same target after the package deploy step succeeds.

```
$cloud = Get-JawsCloudAccount -Name "prod-azure"
$rg    = $Variables['Azure.ResourceGroup']
$site  = $Variables['Azure.SiteName']

Switch-AzureWebAppSlot `
    -CloudAccount $cloud `
    -ResourceGroup $rg `
    -SiteName $site `
    -FromSlot 'staging' `
    -ToSlot 'production'
```

> **// Configuration - Use Azure App Settings for environment-specific runtime config.**
> 
> The Azure Web App step can push App Settings as part of the deployment. Map Jaws Deploy variables to App Settings keys so the environment's values land on the slot.

