Skip to content
Latchkey

How to Run a Scheduled Nightly Deploy in Azure Pipelines

A schedules cron entry runs the deploy on a fixed timetable, independent of any push.

Add a schedules block with a cron expression and the branch to build. The pipeline runs at each scheduled time and deploys to your target.

Steps

  • Add a schedules block with a cron expression (UTC).
  • List the branches to build on the schedule.
  • Set always: true if you want it to run even without new commits.
  • Deploy to a non-prod environment on the schedule.

azure-pipelines.yml

azure-pipelines.yml
schedules:
  - cron: '0 2 * * *'
    displayName: Nightly staging deploy
    branches:
      include: [main]
    always: true
pool:
  vmImage: ubuntu-latest
steps:
  - script: npm ci && npm run build
  - task: AzureWebApp@1
    inputs:
      azureSubscription: 'my-azure-rm'
      appName: 'staging-web-app'
      package: '$(Build.ArtifactStagingDirectory)/app.zip'

Gotchas

  • Cron times are UTC; account for daylight saving when picking the hour.
  • Without always: true, a scheduled run is skipped when the branch has no new commits.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →