Skip to content

Commit 4b40a77

Browse files
author
Facundo Sentena
committed
readme .md updated
1 parent 0465ebf commit 4b40a77

1 file changed

Lines changed: 24 additions & 24 deletions

File tree

databricks_job_executor/README.md

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ A Streamlit application for executing and monitoring Databricks migration jobs.
1616
- Python 3.8+
1717
- Streamlit
1818
- Databricks workspace access
19-
- Databricks personal access token
19+
- Databricks service principal with OAuth M2M credentials (client ID and client secret)
2020

2121
### Installation
2222

@@ -28,14 +28,16 @@ pip install -r requirements.txt
2828
2. Set environment variables:
2929
```bash
3030
export DATABRICKS_HOST="https://your-workspace.cloud.databricks.com"
31-
export DATABRICKS_TOKEN="your-personal-access-token"
31+
export DATABRICKS_CLIENT_ID="your-client-id"
32+
export DATABRICKS_CLIENT_SECRET="your-client-secret"
3233
export DATABRICKS_JOB_ID="123456" # Optional: specific job ID to run
3334
```
3435

3536
Or create a `.env` file:
3637
```
3738
DATABRICKS_HOST=https://your-workspace.cloud.databricks.com
38-
DATABRICKS_TOKEN=your-personal-access-token
39+
DATABRICKS_CLIENT_ID=your-client-id
40+
DATABRICKS_CLIENT_SECRET=your-client-secret
3941
DATABRICKS_JOB_ID=123456
4042
```
4143

@@ -86,10 +88,15 @@ This application can be deployed to Databricks using Databricks Asset Bundles.
8688

8789
The application requires the following environment variables:
8890

89-
- **DATABRICKS_HOST** (required): Your Databricks workspace URL (e.g., `https://your-workspace.cloud.databricks.com`)
90-
- **DATABRICKS_TOKEN** (required): Your Databricks personal access token
91+
- **DATABRICKS_HOST** (required for local): Your Databricks workspace URL (e.g., `https://your-workspace.cloud.databricks.com`)
92+
- **DATABRICKS_CLIENT_ID** (required for local): Your service principal client ID
93+
- **DATABRICKS_CLIENT_SECRET** (required for local): Your service principal client secret
9194
- **DATABRICKS_JOB_ID** (required): The specific job ID to run
9295

96+
**Authentication Methods:**
97+
- **Local Development**: Uses OAuth M2M (service principal) with `DATABRICKS_CLIENT_ID` and `DATABRICKS_CLIENT_SECRET`
98+
- **Databricks Runtime**: Automatically uses built-in authentication (no credentials needed)
99+
93100
These credentials are read from environment variables at startup. The connection status is displayed in the sidebar.
94101

95102
## Usage
@@ -104,7 +111,7 @@ These credentials are read from environment variables at startup. The connection
104111

105112
## Security Note
106113

107-
Never commit your `DATABRICKS_TOKEN` to version control. Always use environment variables or secure credential management systems.
114+
Never commit your `DATABRICKS_CLIENT_SECRET` to version control. Always use environment variables or secure credential management systems (e.g., Databricks Secrets).
108115

109116
### Setting Environment Variables and Secrets on Databricks
110117

@@ -126,33 +133,26 @@ When deploying and running the Streamlit app on Databricks, you can configure th
126133
# MY_CUSTOM_VAR: "value"
127134
```
128135

129-
2. **Databricks Widgets (for `DATABRICKS_HOST`, `DATABRICKS_TOKEN`, `DATABRICKS_JOB_ID`)**:
130-
When you launch a Databricks App, you can pass parameters as widgets. The Streamlit app is configured to read `databricks_host`, `databricks_token`, and `databricks_job_id` from these widgets if they are present.
136+
2. **Databricks App Configuration**:
137+
When deploying to Databricks as an app, authentication is handled automatically using the Databricks runtime's built-in authentication. No explicit credentials (client ID/secret) are needed when running on Databricks.
131138
132-
To set widgets when launching the app:
133-
* Go to your Databricks workspace.
134-
* Navigate to "Apps" (or the equivalent section where deployed apps are listed).
135-
* Select your deployed app (e.g., `databricks-job-executor-streamlit`).
136-
* Click "Launch" or "Run App".
137-
* In the launch dialog, you may find options to set parameters. If not directly available, you might need to configure them in the `databricks.yml` or rely on secrets.
138-
* `databricks_host`: `https://your-workspace.cloud.databricks.com`
139-
* `databricks_token`: `dapixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx` (your personal access token)
140-
* `databricks_job_id`: `123456` (the ID of the job you want to execute)
139+
For local development configuration, you can optionally use Databricks Widgets to pass `databricks_host`, `databricks_client_id`, `databricks_client_secret`, and `databricks_job_id` if needed.
141140
142-
3. **Databricks Secrets (for `DATABRICKS_TOKEN`)**:
143-
For enhanced security, it is recommended to store your `DATABRICKS_TOKEN` in Databricks Secrets. The application will attempt to retrieve the token from a secret scope if it's not provided via environment variables or widgets.
141+
3. **Databricks Secrets (for Local Development)**:
142+
For enhanced security during local development, you can store your OAuth credentials in Databricks Secrets and retrieve them programmatically.
144143
145144
To set up Databricks Secrets:
146145
* **Create a Secret Scope**:
147146
```bash
148-
databricks secrets create-scope --scope databricks-token-scope
147+
databricks secrets create-scope --scope oauth-credentials
149148
```
150149
(You might need to configure ACLs for this scope to allow users/groups to read it.)
151-
* **Put the Secret**:
150+
* **Put the Secrets**:
152151
```bash
153-
databricks secrets put --scope databricks-token-scope --key databricks-token-key
152+
databricks secrets put --scope oauth-credentials --key client-id
153+
databricks secrets put --scope oauth-credentials --key client-secret
154154
```
155-
When prompted, paste your Databricks personal access token.
155+
When prompted, enter your service principal credentials.
156156
157-
The application will then automatically attempt to retrieve the token using `dbutils.secrets.get("databricks-token-scope", "databricks-token-key")` when running in the Databricks environment.
157+
**Note**: When running on Databricks as an app, the runtime automatically handles authentication, so explicit credential storage is not required.
158158

0 commit comments

Comments
 (0)