Deploying user code in Azure Container Registry (ACR) with Dagster+#
This quickstart guide will walk you through setting up a new repository for your Dagster code, setting up CI/CD with GitHub Actions backed by Azure Container Registry (ACR), and deploying your code to your Azure Kubernetes Service (AKS) cluster.
This guide assumes you already have an AKS agent running. You can follow along here if you still need to set up an AKS agent.
This guide will use a Github repository to store the Dagster code, and GitHub Actions to deploy the code to Azure Container Registry. If you need to use another CI/CD provider, such as Azure DevOps, the steps here will need to be adapted. Check out our guide on configuring CI/CD using the dagster-cloud CLI here.
The azure CLI installed on your machine. You can download it here.
A GitHub account, and the ability to run GitHub Actions workflows in a repository.
We'll create a new repository based on the Dagster+ hybrid quickstart repository. We'll go through these steps using a brand new repository in GitHub, but you should be able to adapt these steps to an existing repository or other version control systems.
Now, we'll set up a Github Actions workflow to build and push our Docker image to Azure Container Registry.
We already have a GitHub Actions workflow in our repository, located at .github/workflows/dagster-cloud-deploy.yml. This workflow will build the Docker image, push it to ACR, and update the code location in Dagster+. To get it working with your repository, you'll need to do a few things.
First, we'll need to generate a service principal for GitHub Actions to use to authenticate with Azure. We'll use the Azure CLI to create the service principal.
az ad sp create-for-rbac --name "github-actions-acr" --role contributor --scopes /subscriptions/<your_azure_subscription_id>/resourceGroups/<your_resource_group>/providers/Microsoft.ContainerRegistry/registries/<your_acr_name>
This command will output a JSON object with the service principal details. Make sure to save the appId and password values - we'll use them in the next step.
We'll add the service principal details as secrets in our repository. Go to your repository in GitHub, and navigate to Settings -> Secrets. Add the following secrets:
For this step, open .github/workflows/dagster-cloud-deploy.yml in your repository with your preferred text editor to perform the changes below.
In the env section of the workflow, update the following variables:
DAGSTER_CLOUD_ORGANIZATION: The name of your Dagster Cloud organization.
IMAGE_REGISTRY: The URL of your Azure Container Registry: <your-acr-name>.azurecr.io.
We'll update the workflow to use the Azure Container Registry by uncommenting its section and providing the principal details. It should look like this:
Update the dagster_cloud.yaml build configuration to use the Azure Container Registry#
Edit the dagster_cloud.yaml file in the root of your repository. Update the build section to use the Azure Container Registry, and provide an image name specific to the code location. This must match the registry and image name used in the previous step.
Now, commit and push the changes to your repository. The GitHub Actions workflow should run automatically. You can check the status of the workflow in the Actions tab of your repository.
When the workflow completes, you should see the new code location in Dagster+. Navigate to the Status page, and click the Code Locations tab. You should see your new code location listed.