Hi @Rob_Lemmens,
To programmatically renew OAuth secrets for a Service Principal every 2 months, you can follow these steps:
- Create a Service Principal and OAuth Secret:
- Store the Secret in Azure Key Vault:
- Store the generated OAuth secret in Azure Key Vault for secure access.
- Automate Secret Renewal:
- Use Azure Functions or Azure Automation to create a scheduled task that runs every 2 months.
- The task should:
- Generate a new OAuth secret using the Databricks REST API.
- Update the secret in Azure Key Vault.
- Update .databrickscfg File:
- Ensure your DevOps pipeline retrieves the latest secret from Azure Key Vault and updates the .databrickscfg file before using the Databricks CLI.
Example Azure Function to Renew OAuth Secret
import os
import requests
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
# Azure Key Vault details
key_vault_name = os.environ[
https://learn.microsoft.com/en-us/azure/databricks/dev-tools/auth/oauth-m2m