App Service

Deploy and manage Azure App Service web applications.

Operations

Operation Description
AppService.DeployZip
Deploy an app service using zip deploy. Same name as Functions.DeployZip: AppService always uses OneDeploy (az webapp deploy); Functions defaults to config-zip for plan compatibility and offers OneDeploy with WithOneDeploy().
AppService.DeployFolder
Zip a published folder (contents at the archive root) and deploy it with zip deploy. Use when you have a publish directory rather than a pre-built zip. Supports WithDeploymentSlot. Passes --restart false unless WithRestart() is set (then --restart true) and waits for the deployment unless WithNoWait() is set. Deploys use az webapp deploy --type zip. Installs zip with apt in the container if missing; for reproducible builds zip at build time and use DeployZip.
AppService.DeployWithSwap
Deploy to a slot then swap to production (zero-downtime). Same name as Functions.DeployWithSwap: AppService uses OneDeploy (az webapp deploy), Functions uses config-zip (az functionapp deployment source config-zip) for plan compatibility.
AppService.SwapSlots
Swap deployment slots. Returns a CommandStep (chain .WithTimeout(...)). The default timeout is 30 minutes, or Ando.CommandTimeout when that is longer; an explicit .WithTimeout always wins. Same name as Functions.SwapSlots: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.CreateSlot
Create a new deployment slot. Same name as Functions.CreateSlot: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.DeleteSlot
Delete a deployment slot. Same name as Functions.DeleteSlot: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.ListSlots
List deployment slots for an app service. Same name as Functions.ListSlots: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.Restart
Restart an app service. Returns a CommandStep. Same name as Functions.Restart: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.Start
Start an app service. Returns a CommandStep. Same name as Functions.Start: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.Stop
Stop an app service. Returns a CommandStep. Same name as Functions.Stop: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.Show
Reads the app's (or slot's) az webapp show JSON. Returns a CommandStep; the output is quiet. Read fields at execution time with Json(path). Same name as Functions.Show: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.GetHostName
Reads the app's (or slot's) default host name, for example myapp-release.azurewebsites.net. Returns a CommandStep. Same name as Functions.GetHostName: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.AccessRestrictions
Reads the app's (or slot's) access restrictions (az webapp config access-restriction show). Returns a quiet CommandStep with JSON. Same name as Functions.AccessRestrictions: same behavior, only the az subcommand differs (az webapp here, az functionapp there).
AppService.TemporaryAccessRule
Adds an Allow access rule for one IPv4 address to the app or slot and removes it again when the enclosing block (or the run) ends, whatever happened. The removal is a finally step, followed by a check that the rule is gone. A rule with the same name is replaced. Without ip, uses this machine's public IPv4; a bare address gets /32. Signature: TemporaryAccessRule(appName, resourceGroup, slot = null, ruleName = "ando-deploy", ip = null, priority = 50). Call it directly in the Ando.Block that needs it: inside Ando.When or Ando.Defer the rule is removed when that body ends. Same name as Functions.TemporaryAccessRule: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

Operation Details

AppService.DeployZip source

Deploy an app service using zip deploy. Same name as Functions.DeployZip: AppService always uses OneDeploy (az webapp deploy); Functions defaults to config-zip for plan compatibility and offers OneDeploy with WithOneDeploy().

AppService.DeployZip("my-app", "./publish.zip");
AppService.DeployZip("my-app", "./publish.zip", "my-rg", o => o
  .WithDeploymentSlot("staging"));

AppService.DeployFolder source

Zip a published folder (contents at the archive root) and deploy it with zip deploy. Use when you have a publish directory rather than a pre-built zip. Supports WithDeploymentSlot. Passes --restart false unless WithRestart() is set (then --restart true) and waits for the deployment unless WithNoWait() is set. Deploys use az webapp deploy --type zip. Installs zip with apt in the container if missing; for reproducible builds zip at build time and use DeployZip.

AppService.DeployFolder("my-app", "dist/api");
AppService.DeployFolder("my-app", "dist/api", "my-rg", o => o
  .WithDeploymentSlot("release"));

AppService.DeployWithSwap source

Deploy to a slot then swap to production (zero-downtime). Same name as Functions.DeployWithSwap: AppService uses OneDeploy (az webapp deploy), Functions uses config-zip (az functionapp deployment source config-zip) for plan compatibility.

AppService.DeployWithSwap("my-app", "./publish.zip");
AppService.DeployWithSwap("my-app", "./publish.zip", "staging", "my-rg");

AppService.SwapSlots source

Swap deployment slots. Returns a CommandStep (chain .WithTimeout(...)). The default timeout is 30 minutes, or Ando.CommandTimeout when that is longer; an explicit .WithTimeout always wins. Same name as Functions.SwapSlots: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

AppService.SwapSlots("my-app", "staging");
AppService.SwapSlots("my-app", "staging", "my-rg", "production");
AppService.SwapSlots("my-app", "staging", "my-rg").WithTimeout(TimeSpan.FromMinutes(45));

AppService.CreateSlot source

Create a new deployment slot. Same name as Functions.CreateSlot: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

AppService.CreateSlot("my-app", "staging");
AppService.CreateSlot("my-app", "staging", "my-rg", "production");

AppService.DeleteSlot source

Delete a deployment slot. Same name as Functions.DeleteSlot: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

AppService.DeleteSlot("my-app", "staging");
AppService.DeleteSlot("my-app", "staging", "my-rg");

AppService.ListSlots source

List deployment slots for an app service. Same name as Functions.ListSlots: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

AppService.ListSlots("my-app");
AppService.ListSlots("my-app", "my-rg");

AppService.Restart source

Restart an app service. Returns a CommandStep. Same name as Functions.Restart: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

AppService.Restart("my-app");
AppService.Restart("my-app", "my-rg", "staging");

AppService.Start source

Start an app service. Returns a CommandStep. Same name as Functions.Start: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

AppService.Start("my-app");
AppService.Start("my-app", slot: "staging");

AppService.Stop source

Stop an app service. Returns a CommandStep. Same name as Functions.Stop: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

AppService.Stop("my-app");
AppService.Stop("my-app", slot: "staging");

AppService.Show source

Reads the app's (or slot's) az webapp show JSON. Returns a CommandStep; the output is quiet. Read fields at execution time with Json(path). Same name as Functions.Show: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

var show = AppService.Show("my-app", "my-rg", "release");
Ando.Require(() => show.Json("state") == "Running", "Slot is not running");

AppService.GetHostName source

Reads the app's (or slot's) default host name, for example myapp-release.azurewebsites.net. Returns a CommandStep. Same name as Functions.GetHostName: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

var host = AppService.GetHostName("my-app", "my-rg", "release");
Http.WaitForHealthy(() => $"https://{host.Value}/healthz");

AppService.AccessRestrictions source

Reads the app's (or slot's) access restrictions (az webapp config access-restriction show). Returns a quiet CommandStep with JSON. Same name as Functions.AccessRestrictions: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

var rules = AppService.AccessRestrictions("my-app", "my-rg", "release");
Ando.When(() => rules.Json("ipSecurityRestrictionsDefaultAction") == "Deny", () => Log.Info("restricted"));

AppService.TemporaryAccessRule source

Adds an Allow access rule for one IPv4 address to the app or slot and removes it again when the enclosing block (or the run) ends, whatever happened. The removal is a finally step, followed by a check that the rule is gone. A rule with the same name is replaced. Without ip, uses this machine's public IPv4; a bare address gets /32. Signature: TemporaryAccessRule(appName, resourceGroup, slot = null, ruleName = "ando-deploy", ip = null, priority = 50). Call it directly in the Ando.Block that needs it: inside Ando.When or Ando.Defer the rule is removed when that body ends. Same name as Functions.TemporaryAccessRule: same behavior, only the az subcommand differs (az webapp here, az functionapp there).

Ando.Block("deploy", () =>
{
  AppService.TemporaryAccessRule("my-app", "my-rg", "release", "deploy-gate");
  AppService.DeployFolder("my-app", "dist/api", "my-rg", o => o.WithDeploymentSlot("release"));
});

AppService or Functions?

AppService and Functions have the same operations with the same signatures: DeployZip, DeployWithSwap, SwapSlots, Restart, Start, Stop, Show, GetHostName, AccessRestrictions, TemporaryAccessRule, ListSlots, CreateSlot and DeleteSlot. Apart from the az subcommand, the zip deploy differs: AppService always uses OneDeploy (az webapp deploy), while Functions.DeployZip defaults to config-zip for plan compatibility. Pick by the resource you deploy to:

AppServiceFunctions
TargetsApp Service web apps (az webapp)Azure Functions apps (az functionapp)
Only hereDeployFolder (zips a publish folder and deploys it)Publish
Pagethis pageFunctions

Passing a function app name to the wrong provider fails because the az command does not find the resource.

Example

Deploy a web app with zero-downtime using deployment slots.

// Build and publish the web app
var WebApp = Dotnet.Project("./src/WebApp/WebApp.csproj");
Dotnet.Publish(WebApp, o => o
  .Output(Root / "publish")
  .WithConfiguration(Configuration.Release));

// Create a reproducible zip for deployment
Archive.Zip("publish", "app.zip", o => o.WithTimestamp(Git.CommitTime));

// Deploy to staging slot, then swap to production
AppService.DeployWithSwap("my-web-app", Root / "app.zip");

// Or deploy directly to a specific slot
AppService.DeployZip("my-web-app", Root / "app.zip", "my-rg", o => o
  .WithDeploymentSlot("staging"));

// Or skip the manual zip and deploy the publish folder directly
// (contents are placed at the archive root, as zip deploy expects)
AppService.DeployFolder("my-web-app", Root / "publish", "my-rg", o => o
  .WithDeploymentSlot("staging"));

Options Reference

AppService.DeployZip Options

OptionDescription
WithDeploymentSlot(string)Deploy to a specific slot instead of production. Common slots: “staging”, “dev”, “canary”. Slots have their own URLs and can be swapped with production.
WithNoWait()Pass --async true to az webapp deploy. Azure CLI 2.87 still polls the deployment status in some cases, so the step may not return immediately. By default the deploy is synchronous (--async false).
WithRestart()Pass --restart true to az webapp deploy, so the app restarts after the deployment. Without it ANDO passes --restart false, because az webapp deploy restarts the site by default, which could start a slot you stopped on purpose.
WithTimeout(TimeSpan)Maximum time to wait for the zip deploy command before reconciling and retrying. Also passed to az as --timeout. Must be greater than zero. Default 20 minutes.

Resilient zip deploy

AppService.DeployZip (and the operations built on it) tolerate the flaky behaviour Azure App Service sometimes exhibits during large uploads:

  • Timeout reconciliation. If the az webapp deploy command times out, ANDO queries the latest Kudu deployment status. When Kudu reports the deployment completed successfully after the command timed out, the step is treated as successful instead of failing.
  • Automatic retries. Transient failures (HTTP 5xx, “Service Unavailable”, connection resets) are retried with backoff, up to three attempts, as long as the overall WithTimeout budget has not been exhausted.

Deploys use az webapp deploy --type zip with --restart false --async false (--restart true with WithRestart(), --async true with WithNoWait()).

DeployFolder zips the folder itself and installs zip with apt in the container if it is missing (Debian and Ubuntu images). The image mcr.microsoft.com/dotnet/sdk:10.0 (Ubuntu 24.04) does not include zip. For reproducible builds, zip at build time (so the same bytes are deployed every time) and use DeployZip.

Reading app state

These steps return a CommandStep. Read the result at execution time, for example in Ando.When, Ando.Require or a Func<> overload. See the Ando provider page for the step model.

OperationDescription
AppService.Show(app, rg?, slot?)The app’s (or slot’s) az webapp show JSON. Quiet. Read fields with Json("state").
AppService.GetHostName(app, rg?, slot?)The default host name, for example myapp-release.azurewebsites.net. Value is the host name.
AppService.AccessRestrictions(app, rg?, slot?)The az webapp config access-restriction show JSON. Quiet.
var host = AppService.GetHostName("my-web-app", "my-rg", "release");
Http.WaitForHealthy(() => $"https://{host.Value}/healthz");

var show = AppService.Show("my-web-app", "my-rg", "release");
Ando.Require(() => show.Json("state") == "Running", "The release slot is not running");

Temporary access rule

AppService.TemporaryAccessRule(app, rg, slot = null, ruleName = "ando-deploy", ip = null, priority = 50) adds an Allow access rule for one IPv4 address to the app or slot, so the build can reach a restricted site. It removes the rule again when the enclosing Ando.Block (or the run) ends, whatever happened: the removal is a finally step, followed by a check that the rule is gone. An existing rule with the same name is replaced.

Without ip, ANDO uses this machine’s public IPv4 address. A bare address gets /32; a CIDR range is used as given.

It can also be called inside Ando.When or Ando.Defer (for example only when the slot denies traffic by default); the rule is still removed when the enclosing block ends.

Ando.Block("deploy", () =>
{
    AppService.TemporaryAccessRule("my-web-app", "my-rg", "release", "deploy-gate");
    AppService.DeployFolder("my-web-app", Root / "publish", "my-rg", o => o
      .WithDeploymentSlot("release"));
    Http.WaitForHealthy(() => $"https://{host.Value}/healthz");
});