Azure Functions

Deploy and manage Azure Functions apps.

Operations

Operation Description
Functions.DeployZip
Deploy a function app with zip deploy. The app must already exist. Default: az functionapp deployment source config-zip --name N [--resource-group RG] --src ZIP [--slot S] [--timeout <seconds>] --output none, which supports every plan, including dedicated and Premium, Linux Consumption (storage upload plus WEBSITE_RUN_FROM_PACKAGE) and Flex. Opt-in OneDeploy: WithOneDeploy() switches to az functionapp deploy --src-path ZIP --type zip [--slot S] --restart false|true --async false|true [--timeout <ms>]. That command is preview and posts to /api/publish; it fits dedicated, Premium and Flex plans and is not guaranteed on Linux Consumption. Options: WithDeploymentSlot (--slot), WithTimeout(TimeSpan) (both paths, default 20 minutes), WithOneDeploy(), and, OneDeploy only, WithRestart() (--restart true; the default is false because OneDeploy restarts by default) and WithNoWait() (--async true). Behavior change: WithRestart() and WithNoWait() without WithOneDeploy() throw. Transient 5xx and connection errors are retried 3 times on both paths; after a timeout only OneDeploy checks az functionapp log deployment show, a timed-out config-zip fails. Compare AppService.DeployZip, which always uses OneDeploy (az webapp deploy); Functions defaults to config-zip for plan compatibility.
Functions.Publish
Publish using Azure Functions Core Tools (func azure functionapp publish). The func CLI must be available. AppService has no equivalent; use AppService.DeployFolder there.
Functions.DeployWithSwap
Deploy to a slot then swap to production (zero-downtime). Same name as AppService.DeployWithSwap: Functions uses config-zip (az functionapp deployment source config-zip) for plan compatibility, AppService uses OneDeploy (az webapp deploy). Uses config-zip for the deploy step.
Functions.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 AppService.SwapSlots: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.Restart
Restart a function app. Returns a CommandStep. Same name as AppService.Restart: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.Show
Reads the function app's (or slot's) az functionapp show JSON. Returns a CommandStep; the output is quiet. Read fields at execution time with Json(path). Signature: Show(name, rg = null, slot = null). Same name as AppService.Show: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.Start
Start a function app. Returns a CommandStep. Same name as AppService.Start: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.Stop
Stop a function app. Returns a CommandStep. Same name as AppService.Stop: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.GetHostName
Reads the app's (or slot's) default host name with az functionapp show --query defaultHostName -o tsv. Returns a CommandStep. Signature: GetHostName(name, rg = null, slot = null). Same name as AppService.GetHostName: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.AccessRestrictions
Reads the app's (or slot's) access restrictions (az functionapp config access-restriction show). Returns a quiet CommandStep with JSON. Signature: AccessRestrictions(name, rg = null, slot = null). Same name as AppService.AccessRestrictions: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.TemporaryAccessRule
Adds an Allow access rule for one IPv4 address to the function app or slot and removes it again when the enclosing block (or the run) ends, whatever happened. The removal is a finally step (Functions.RemoveAccessRule), 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(name, 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 AppService.TemporaryAccessRule: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.ListSlots
List deployment slots for a function app. Signature: ListSlots(name, rg = null). Same name as AppService.ListSlots: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.CreateSlot
Create a deployment slot, optionally cloning configuration from another slot. Signature: CreateSlot(name, slot, rg = null, configurationSource = null). Same name as AppService.CreateSlot: same behavior, only the az subcommand differs (az functionapp here, az webapp there).
Functions.DeleteSlot
Delete a deployment slot. Signature: DeleteSlot(name, slot, rg = null). Same name as AppService.DeleteSlot: same behavior, only the az subcommand differs (az functionapp here, az webapp there).

Operation Details

Functions.DeployZip source

Deploy a function app with zip deploy. The app must already exist. Default: az functionapp deployment source config-zip --name N [--resource-group RG] --src ZIP [--slot S] [--timeout <seconds>] --output none, which supports every plan, including dedicated and Premium, Linux Consumption (storage upload plus WEBSITE_RUN_FROM_PACKAGE) and Flex. Opt-in OneDeploy: WithOneDeploy() switches to az functionapp deploy --src-path ZIP --type zip [--slot S] --restart false|true --async false|true [--timeout <ms>]. That command is preview and posts to /api/publish; it fits dedicated, Premium and Flex plans and is not guaranteed on Linux Consumption. Options: WithDeploymentSlot (--slot), WithTimeout(TimeSpan) (both paths, default 20 minutes), WithOneDeploy(), and, OneDeploy only, WithRestart() (--restart true; the default is false because OneDeploy restarts by default) and WithNoWait() (--async true). Behavior change: WithRestart() and WithNoWait() without WithOneDeploy() throw. Transient 5xx and connection errors are retried 3 times on both paths; after a timeout only OneDeploy checks az functionapp log deployment show, a timed-out config-zip fails. Compare AppService.DeployZip, which always uses OneDeploy (az webapp deploy); Functions defaults to config-zip for plan compatibility.

Functions.DeployZip("my-func", "./publish.zip");
Functions.DeployZip(app, "out/func.zip", rg, o => o.WithDeploymentSlot("release").WithTimeout(TimeSpan.FromMinutes(30)));
// OneDeploy (preview) with restart
Functions.DeployZip(app, "out/func.zip", rg, o => o.WithOneDeploy().WithRestart());

Functions.Publish source

Publish using Azure Functions Core Tools (func azure functionapp publish). The func CLI must be available. AppService has no equivalent; use AppService.DeployFolder there.

Functions.Publish("my-func");
Functions.Publish("my-func", "./src/MyFunc", o => o
  .WithDeploymentSlot("staging")
  .WithConfiguration("Release"));

Functions.DeployWithSwap source

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

Functions.DeployWithSwap("my-func", "./publish.zip");
Functions.DeployWithSwap("my-func", "./publish.zip", "staging", "my-rg");

Functions.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 AppService.SwapSlots: same behavior, only the az subcommand differs (az functionapp here, az webapp there).

Functions.SwapSlots("my-func", "staging");
Functions.SwapSlots("my-func", "staging", "my-rg", "production");

Functions.Restart source

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

Functions.Restart("my-func");
Functions.Restart("my-func", "my-rg", "staging");

Functions.Show source

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

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

Functions.Start source

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

Functions.Start("my-func");
Functions.Start("my-func", slot: "staging");

Functions.Stop source

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

Functions.Stop("my-func");
Functions.Stop("my-func", "my-rg", "release");

Functions.GetHostName source

Reads the app's (or slot's) default host name with az functionapp show --query defaultHostName -o tsv. Returns a CommandStep. Signature: GetHostName(name, rg = null, slot = null). Same name as AppService.GetHostName: same behavior, only the az subcommand differs (az functionapp here, az webapp there).

var h = Functions.GetHostName(app, rg, "release");
Http.WaitForHealthy(() => $"https://{h.Value}/api/health");

Functions.AccessRestrictions source

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

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

Functions.TemporaryAccessRule source

Adds an Allow access rule for one IPv4 address to the function app or slot and removes it again when the enclosing block (or the run) ends, whatever happened. The removal is a finally step (Functions.RemoveAccessRule), 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(name, 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 AppService.TemporaryAccessRule: same behavior, only the az subcommand differs (az functionapp here, az webapp there).

Ando.Block("deploy", () =>
{
  Functions.TemporaryAccessRule("my-func", "my-rg", "release", "deploy-gate");
  Functions.DeployZip("my-func", "out/func.zip", "my-rg", o => o.WithDeploymentSlot("release"));
});

Functions.ListSlots source

List deployment slots for a function app. Signature: ListSlots(name, rg = null). Same name as AppService.ListSlots: same behavior, only the az subcommand differs (az functionapp here, az webapp there).

Functions.ListSlots("my-func");
Functions.ListSlots("my-func", "my-rg");

Functions.CreateSlot source

Create a deployment slot, optionally cloning configuration from another slot. Signature: CreateSlot(name, slot, rg = null, configurationSource = null). Same name as AppService.CreateSlot: same behavior, only the az subcommand differs (az functionapp here, az webapp there).

Functions.CreateSlot("my-func", "staging");
Functions.CreateSlot("my-func", "staging", "my-rg", "production");

Functions.DeleteSlot source

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

Functions.DeleteSlot("my-func", "staging");
Functions.DeleteSlot("my-func", "staging", "my-rg");

Functions or AppService?

Functions and AppService 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 and uses OneDeploy only with WithOneDeploy(). Pick by the resource you deploy to:

FunctionsAppService
TargetsAzure Functions apps (az functionapp)App Service web apps (az webapp)
Only herePublish (Azure Functions Core Tools, func azure functionapp publish)DeployFolder
Pagethis pageAppService

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

Example

Deploy a function app with zero-downtime using slot swap.

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

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

// Deploy with zero-downtime swap
Functions.DeployWithSwap("my-func-app", Root / "func.zip");

Options Reference

Functions.DeployZip Options

OptionDescription
WithDeploymentSlot(string)Deploy to a specific slot instead of production (--slot).
WithOneDeploy()Use OneDeploy (az functionapp deploy --type zip, preview) instead of the default config-zip. See Zip deploy.
WithNoWait()OneDeploy only. Pass --async true. By default the deployment is awaited (--async false).
WithRestart()OneDeploy only. Pass --restart true. Without it ANDO passes --restart false, because OneDeploy restarts the app by default, which could start a slot you stopped on purpose.
WithTimeout(TimeSpan)Maximum time to wait for the deploy command before retrying; also passed to az as --timeout (seconds for config-zip, milliseconds for OneDeploy). Works on both paths. Must be greater than zero. Default 20 minutes.

Functions.Publish Options

OptionDescription
WithDeploymentSlot(string)Publish to a specific slot.
WithConfiguration(string)Build configuration. Values: “Release”, “Debug”.
WithForceRestart()Force restart the function app after publishing.
WithNoWait()Don’t wait for the deployment to complete.

Zip deploy

Functions.DeployZip has two mechanisms.

Default: config-zip. Runs az functionapp deployment source config-zip --name N [--resource-group RG] --src ZIP [--slot S] [--timeout <seconds>] --output none. It supports every plan: dedicated and Premium, Linux Consumption (the zip is uploaded to storage and WEBSITE_RUN_FROM_PACKAGE is set) and Flex Consumption. DeployWithSwap uses this path.

Opt-in: WithOneDeploy(). Runs az functionapp deploy --src-path ZIP --type zip [--slot S] --restart false|true --async false|true [--timeout <ms>]. This command is in preview and posts to /api/publish. It fits dedicated, Premium and Flex plans and is not guaranteed on Linux Consumption. AppService.DeployZip always uses OneDeploy (az webapp deploy).

  • WithRestart() and WithNoWait() need WithOneDeploy(): without it DeployZip throws, because config-zip has no restart or async option. (Behavior change: these two options used to apply without it.)
  • WithTimeout and WithDeploymentSlot work on both paths.
  • Transient failures (HTTP 5xx, connection resets) are retried up to 3 times on both paths.
  • After a timeout, only OneDeploy checks az functionapp log deployment show and treats a deployment that completed anyway as successful. A timed-out config-zip fails.
// Default (all plans)
Functions.DeployZip(app, "out/func.zip", rg, o => o
    .WithDeploymentSlot("release")
    .WithTimeout(TimeSpan.FromMinutes(30)));

// OneDeploy (preview): restart after the deploy
Functions.DeployZip(app, "out/func.zip", rg, o => o
    .WithOneDeploy()
    .WithRestart());

Reading app state and gating deploys

SwapSlots, Restart, Stop, Start, Show, GetHostName and AccessRestrictions return a CommandStep; read the result at execution time (see the Ando provider page, “Step model”). SwapSlots has a 30-minute default timeout.

OperationDescription
Functions.Show(app, rg?, slot?)The app’s (or slot’s) az functionapp show JSON. Quiet. Read fields with Json("state").
Functions.GetHostName(app, rg?, slot?)The default host name (az functionapp show --query defaultHostName -o tsv). Value is the host name.
Functions.AccessRestrictions(app, rg?, slot?)az functionapp config access-restriction show JSON. Quiet.
Functions.TemporaryAccessRule(app, rg, slot?, ruleName = "ando-deploy", ip?, priority = 50)Adds an Allow rule for one IPv4 address (default: this machine’s public IP) and removes it in a finally step (Functions.RemoveAccessRule) when the enclosing block or run ends.
Functions.ListSlots(app, rg?), CreateSlot(app, slot, rg?, configurationSource?), DeleteSlot(app, slot, rg?)Manage deployment slots.
var h = Functions.GetHostName(app, rg, "release");
Ando.Block("deploy", () =>
{
    Functions.TemporaryAccessRule(app, rg, "release", "deploy-gate");
    Functions.DeployZip(app, "out/func.zip", rg, o => o.WithDeploymentSlot("release"));
    Http.WaitForHealthy(() => $"https://{h.Value}/api/health");
    Functions.SwapSlots(app, "release", rg);
});