App Service

Deploy and manage Azure App Service web applications.

Operations

Operation Description
AppService.DeployZip
Deploy an app service using zip deploy.
AppService.DeployWithSwap
Deploy to a slot then swap to production (zero-downtime).
AppService.SwapSlots
Swap deployment slots.
AppService.CreateSlot
Create a new deployment slot.
AppService.DeleteSlot
Delete a deployment slot.
AppService.ListSlots
List deployment slots for an app service.
AppService.Restart
Restart an app service.
AppService.Start
Start an app service.
AppService.Stop
Stop an app service.

Operation Details

AppService.DeployZip source

Deploy an app service using zip deploy.

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

AppService.DeployWithSwap source

Deploy to a slot then swap to production (zero-downtime).

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

AppService.SwapSlots source

Swap deployment slots.

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

AppService.CreateSlot source

Create a new deployment slot.

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

AppService.DeleteSlot source

Delete a deployment slot.

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

AppService.ListSlots source

List deployment slots for an app service.

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

AppService.Restart source

Restart an app service.

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

AppService.Start source

Start an app service.

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

AppService.Stop source

Stop an app service.

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

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 zip for deployment
Artifact.Zip(Root / "publish", Root / "app.zip");

// 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"));

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()Don’t wait for deployment to complete. Returns immediately after starting the deployment. Use when you don’t need to verify deployment success in the build.
WithRestart()Restart the app after deployment. Forces the app to pick up new code immediately instead of waiting for the next scheduled restart.