Prerequisites
- A Deployment.
- The Astro CLI.
- An Astro project.
- An existing Azure Key Vault linked to a resource group.
- Your Key Vault URL. To find this, go to your Key Vault overview page > Vault URI.
- (Remote Execution Only) Helm installed
- (Remote Execution Only) The
values.yamlfile from the Register Agents modal in your Deployments>Agents page.
Step 1: Register Astro as an app on Azure
Steps 1 and 2 are only required if you are using service principal (client secret) authentication. If you prefer to use managed identity authentication, skip to Step 3 and follow the Managed Identity tab instructions.
Step 2: Create an access policy
If you use a managed identity to authenticate to Key Vault, skip to Step 3. Ensure your managed identity has an access policy or Azure RBAC role that grants it access to your Key Vault secrets.
- Configure from template: Select
Key, Secret, & Certificate Management. - Select principal: Select the name of the application that you registered in Step 1.
Step 3: Set up Key Vault locally
- Astro
- Remote Execution
In your Astro project, add the following line to your Add the following environment variables to your For client secret authentication, find your client ID in Azure Portal at App Registration page > Application (Client) ID. To find your tenant ID, go to App Registration page > Directory (tenant) ID. To find your client secret, go to App Registration Page > Certificates and Secrets > Client Secrets > Value.Managed identity authentication:Before using managed identity authentication, you must configure your Deployment with a workload identity. See the Azure tab in Authorize a Deployment to cloud resources using workload identity to set up your managed identity and authorize it to your Deployment.
requirements.txt file:requirements.txt
.env file. Choose the option that matches your authentication method:Client secret authentication:airflow/variables/* path in Azure Key Vault and connection information at the airflow/connections/* path. You can now run a dag locally to check that your variables are accessible using Variable.get("<your-variable-key>").
By default, this setup requires that you prefix any secret names in Key Vault with airflow-connections or airflow-variables. If you don’t want to use prefixes in your Key Vault secret names, set the values for sep, "connections_prefix", and "variables_prefix" to "" within AIRFLOW__SECRETS__BACKEND_KWARGS.
Step 4: Deploy configuration
- Astro
- Remote Execution
-
Run the following commands to export your environment variables to Astro.
In the Astro UI, mark
AIRFLOW__SECRETS__BACKEND_KWARGSas Secret. See Set environment variables in the Astro UI. -
Run the following command to push your updated
requirements.txtfile to Astro: -
(Optional) Remove the environment variables from your
.envfile, or store your.envfile so that your credentials are hidden, for example with GitHub secrets.