> ## Documentation Index
> Fetch the complete documentation index at: https://astronomer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Astro CI/CD templates for Azure DevOps

Use the following CI/CD templates to automate deploying Apache Airflow Dags from a Git repository to Astro with [Azure DevOps](https://dev.azure.com/).

The template for Azure DevOps is based on the [image deploy template](/docs/astro/ci-cd-templates/template-overview#image-deploy-templates) with a [single branch implementation](#single-branch-implementation), which requires only one Astro Deployment.

If you use the [Dag-only deploy feature](/docs/astro/deploy-dags) on Astro or you're interested in a multiple-branch implementation, see [Template overview](/docs/astro/ci-cd-templates/template-overview#multiple-branch-implementation) to configure your own. To learn more about CI/CD on Astro, see [Choose a CI/CD strategy](/docs/astro/set-up-ci-cd).

## Prerequisites

* An [Astro project](/docs/cli/v1.43/develop-project#create-an-astro-project) hosted in a Git repository that Azure DevOps can access.
* An [Astro Deployment](/docs/astro/create-deployment).
* A [Deployment API token](/docs/astro/deployment-api-tokens), [Workspace API token](/docs/astro/workspace-api-tokens), or [Organization API token](/docs/astro/organization-api-tokens).
* Access to [Azure DevOps](https://dev.azure.com/).

## Single branch implementation

Complete the following setup in an Azure repository that hosts an Astro project:

1. Set the following environment variable as a [DevOps pipeline variable](https://docs.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops\&tabs=yaml%2Cbatch):

   * `ASTRO_API_TOKEN`: The value for your Workspace or Organization API token.
   * `ASTRO_DEPLOYMENT_ID`: The ID for your Deployment.

   For production Deployments, ensure that you set the value for your API token as a [secret](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops\&tabs=yaml%2Cbatch#secret-variables).

2. Create a new Azure DevOps pipeline named `astro-devops-cicd.yaml` at the root of the repository that includes the following configuration:

   ```yaml title="astro-devops-cicd.yaml" wrap theme={null}
   trigger:
   - main

   pr: none

   stages:
   - stage: deploy
     jobs:
     - job: deploy_image
       pool:
         vmImage: 'ubuntu-latest'
       steps:
       - script: |
           curl -sSL install.astronomer.io | sudo bash -s
           astro deploy ${ASTRO_DEPLOYMENT_ID}
         env:
           ASTRO_API_TOKEN: $(ASTRO_API_TOKEN)
           ASTRO_DEPLOYMENT_ID: $(ASTRO_DEPLOYMENT_ID)
   ```
