Azure-Databricks-Dev-Ops
Complete end to end sample of doing DevOps with Azure Databricks. This is based on working with lots of customers who have requested that they can reference a documented apporach. The included code utilizes KeyVault for each environement and uses Azure AD authorization tokens to call the Databricks REST API.
This will show you how to deploy your Databricks assests via GitHub Actions and Azure Dev Ops Pipelines so that your Notebooks, Clusters, Jobs and Init Scipts are automatically deployed and configured per environment.

Videos

How to deploy this in your subscription
- Create a service principal that will be used for your DevOps pipeline.
- Option A (easy security)
- Add the service principal to the Contributor role to your Subscription.
- Option B (fine grain security)
- Create three resource groups
- Databricks-MyProject-Dev
- Databricks-MyProject-QA
- Databricks-MyProject-Prod
- Grant the service principal to the Contributor role to each Resource Group
Using GitHub Actions
Clone this repo to your GitHub
Click on Settings | Secrets and create a secret named: AZURE_CREDENTIALS
- Add this values of your Service Principal
{
"clientId": "REPLACE:00000000-0000-0000-0000-000000000000",
"clientSecret": "REPLACE: YOUR PASSWORD/SECRET",
"subscriptionId": "REPLACE:00000000-0000-0000-0000-000000000000",
"tenantId": "REPLACE:00000000-0000-0000-0000-000000000000",
"activeDirectoryEndpointUrl": "https://login.microsoftonline.com",
"resourceManagerEndpointUrl": "https://management.azure.com/",
"activeDirectoryGraphResourceId": "https://graph.windows.net/",
"sqlManagementEndpointUrl": "https://management.core.windows.net:8443/",
"galleryEndpointUrl": "https://gallery.azure.com/",
"managementEndpointUrl": "https://management.core.windows.net/"
}
NOTE: When you click on actions you will not see the action if you forked/cloned this repo. I have requested the ability to "import" an existing action. For now you need to create a new action (blank one) and then copy the YAML from the .github/workflows/pipeline.yml file.
Click on Actions and click Databricks-CI-CD and click Run workflow
Fill in the fields (only bold are not the defaults)
- Notebooks Relative Path in Git:
notebooks/MyProject
- Notebooks Deployment Path to Databricks:
/MyProject
- Resource Group Name:
Databricks-MyProject (NOTE: "-Dev" will be appended)
- Azure Region:
EastUS2
- Databricks workspace name:
Databricks-MyProject
- KeyVault name:
KeyVault-MyProject ** NOTE: You need to put a 1 or 2, etc on the end of this to make it globally unique**
- Azure Subscription Id: replace this
00000000-0000-0000-0000-000000000000
- Deployment Mode:
Initialize KeyVault
- Click "Run workflow"
The pipeline will create 3 Azure resource groups
The pipeline will create 3 Databricks workspaces
The pipeline will create 3 Azure KeyVaults (you can use your own KeyVault, see later in this document)
In the Azure Portal
- Go to the KeyVault created in each Azure resource group (repeat this for Dev, QA, Prod)
- Click on Access Policies
- NOTE: You might have to wait a few minutes to add the policies, mine gave a error at first and then was okay.
- Click
Add Access Policy
- Configure from template:
Secret Management
- Key Permissions
0 Selected
- Secret Permissions
2 Selected (select just Get and List)
- Certificate Permissions
0 Selected
- Select your Azure Pipeline Service Principal (you can enter the Client ID (Guid) in the search box)
- Click Add
- Click Save
- Repeat the above steps and add yourself as a Full Secret management. You need to add yourself so you can set the secrets.
- Select the template
Secret Management
- Leave all the Secret Permissions selected
- Select yourself as the Principal
- Click Add
- Click Save
- Click on Secrets
- Click Generate / Import
- You should see 4 secrets:
- databricks-dev-ops-subscription-id
- databricks-dev-ops-tenant-id
- databricks-dev-ops-client-id
- databricks-dev-ops-client-secret
- You need to set these values. These values for a Service Principal that will call over to the Databricks workspace to authenicate to the Databricks REST API.
- Option 1 (Create a new service principal)
- Option 2 (Use the same DevOps service principal)
- In either case you need to make the service principal a contributor of the Databricks workspace or a contributor in the resource group in which the workspace resides. You need to set this in Azure.
- Click on each secret and click "New Version" and set the secret value
- databricks-dev-ops-subscription-id:
00000000-0000-0000-0000-000000000000
- databricks-dev-ops-tenant-id:
00000000-0000-0000-0000-000000000000
- databricks-dev-ops-client-id:
00000000-0000-0000-0000-000000000000
- databricks-dev-ops-client-secret:
some crazy string
Re-run the pipeline
- Set the parameters
- Azure Subscription Id: replace this
00000000-0000-0000-0000-000000000000
- Deployment Mode:
Databricks (this is the default, so you really do not need to select it)
- The pipeline should now deploy your Databricks artifacts
Using Azure DevOps Pipeline
Create an Azure Dev Ops project
Click on the Repo icon on the left menu
- Select "Import"
- Enter the URL:
https://github.com/AdamPaternostro/Azure-Databricks-Dev-Ops
Click on the Pipeline icon on the left menu
- Click "Create Pipeline"
- Click "Azure Repos Git"
- Click on your Repo
- Click the down arrow on the "Run" button and select Save (don't run it, just save it)
Click on the Gear icon (bottom left)
- Click Service Connections
- Click Create Service Connection
- Click Azure Resource Manager
- Click Service Principal (manual)
- Fill in the Fields
- You will need the values from when you created a service principal
- You can name your connection something like "DatabricksDevOpsConnection". Note the name you use.
- NOTE: You can also create a service connection per subscription if you would be deploying to different subscriptions. You would typically have three service principals set for this apporach.
- Click Verify and Save
Click on the Pipeline icon on the left menu
- Select your pipeline
- Click Run
- Fill in the fields (only bold are not the defaults)
- Notebooks Relative Path in Git:
notebooks/MyProject
- Notebooks Deployment Path to Databricks:
/MyProject
- Resource Group Name:
Databricks-MyProject (NOTE: "-Dev" will be appended)
- Azure Region:
EastUS2
- Databricks workspace name:
Databricks-MyProject
- KeyVault name:
KeyVault-MyProject ** NOTE: You need to put a 1 or 2, etc on the end of this to make it globally unique**
- Azure Subscription Id: replace this
00000000-0000-0000-0000-000000000000
- Azure Resource Connection Name:
DatabricksDevOpsConnection
- Deployment Mode:
Initialize KeyVault

- Click "Run"
You should see the following

The first time the pipeline runs it will create your Databricks workspace and KeyVault. It will skip all the other steps!
- The pipeline will create 3 environment Dev, QA, Prod in Azure DevOps
- The pipeline will create 3 Azure resource groups
- The pipeline will create 3 Databricks workspaces
- The pipeline will create 3 Azure KeyVaults (you can use your own KeyVault, see later in this document)
- In the Azure Portal
- Go to the KeyVault created in each Azure resource group (repeat this for Dev, QA, Prod)
- Click on Access Policies
- NOTE: You might have to wait a few minutes to add the policies, mine gave a error at first and then was okay.
- Click
Add Access Policy
- Configure from template:
Secret Management
- Key Permissions
0 Selected
- Secret Permissions
2 Selected (select just Get and List)
- Certificate Permissions
0 Selected
- Select your Azure Pipeline Service Principal (you can enter the Client ID (Guid) in the search box)
- Click Add
- Click Save
- Repeat the above steps and add yourself as a Full Secret management. You need to add yourself so you can set the secrets.
- Select the template
Secret Management
- Leave all the Secret Permissions selected
- Select yourself as the Principal
- Click Add
- Click Save
- Click on Secrets
- Click Generate / Import
- You should see 4 secrets:
- databricks-dev-ops-subscription-id
- databricks-dev-ops-tenant-id
- databricks-dev-ops-client-id
- databricks-dev-ops-client-secret
- You need to set these values. These values for a Service Principal that will call over to the Databricks workspace to authenicate to the Databricks REST API.
- Option 1 (Create a new service principal)
- Option 2 (Use the same DevOps service principal)
- In either case you need to make the service principal a contributor of the Databricks workspace or a contributor in the resource group in which the workspace resides. You need to set this in Azure.
- Click on each secret and click "New Version" and set the secret value
- databricks-dev-ops-subscription-id:
00000000-0000-0000-0000-000000000000
- databricks-dev-ops-tenant-id:
00000000-0000-0000-0000-000000000000
- databricks-dev-ops-client-id:
00000000-0000-0000-0000-000000000000
- databricks-dev-ops-client-secret:
some crazy string
Re-run the pipeline
- Set the parameters
- Azure Subscription Id: replace this
00000000-0000-0000-0000-000000000000
- Azure Resource Connection Name:
DatabricksDevOpsConnection
- Deployment Mode:
Databricks (this is the default, so you really do not need to select it)
- The pipeline should now deploy your Databricks artifacts
Setting Approvals
You shoudl set approvals on each environment so the pipeline does not deploy to QA or Prod without an Approval.
- In Azure DevOps click on the Environments menu on the left
- Click on an Environment
- Clickon the "..." in the top right
- Select on Approvals and checks
- Click on Approvals
- Select a user or group that can approve the deployment to the environment
What Happens during the Pipeline (GitHub Actions / Azure Pipeline)
I typically use the same exact name for each of my Azure resources for each of my environments. I simply append a "-Environment (Dev, QA, Prod)" to make my deployments easy to author in my pipelines. I always suggust an easy naming standard per environment to make your DevOps code easy to write.