Skip to content

Instantly share code, notes, and snippets.

@luebster
Last active March 23, 2022 15:06
Show Gist options
  • Save luebster/d1613ab5e17e0877b1fe1df153a6408f to your computer and use it in GitHub Desktop.
Save luebster/d1613ab5e17e0877b1fe1df153a6408f to your computer and use it in GitHub Desktop.
How to configure Azure deployment slots for reliable auto swaps

Configure warmup ("staging", "preproduction") deployment slot

WEBSITE_SWAP_WARMUP_PING_PATH: /statuscheck WEBSITE_SWAP_WARMUP_PING_STATUSES: 200

Set in every deployment slot, including production

WEBSITE_ADD_SITENAME_BINDINGS_IN_APPHOST_CONFIG: 1 //prevent random cold starts

Create a status check page

This is an example for ASP.NET Core

public class statuscheckModel : PageModel
  {
    private readonly IRepo _repo;

    public statuscheckModel(IRepo repo)
    {
      _repo = repo;
    }

    public StatusCodeResult OnGet()
    {
      // let's get the locations from the repo
      var locations = _repo.Locations;

      // if the object exists and there is more than 1 item, return status ok
      if (locations != null && locations.Count() > 0)
      {
        return StatusCode(StatusCodes.Status200OK);
      }

      return StatusCode(StatusCodes.Status418ImATeapot);
    }
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment