You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -86,10 +88,15 @@ This application can be deployed to Databricks using Databricks Asset Bundles.
86
88
87
89
The application requires the following environment variables:
88
90
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
91
94
- **DATABRICKS_JOB_ID** (required): The specific job ID to run
92
95
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
+
93
100
These credentials are read from environment variables at startup. The connection status is displayed in the sidebar.
94
101
95
102
## Usage
@@ -104,7 +111,7 @@ These credentials are read from environment variables at startup. The connection
104
111
105
112
## Security Note
106
113
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).
108
115
109
116
### Setting Environment Variables and Secrets on Databricks
110
117
@@ -126,33 +133,26 @@ When deploying and running the Streamlit app on Databricks, you can configure th
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.
131
138
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.
*`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.
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.
(You might need to configure ACLs for this scope to allow users/groups to read it.)
151
-
* **Put the Secret**:
150
+
* **Put the Secrets**:
152
151
```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
154
154
```
155
-
When prompted, paste your Databricks personal access token.
155
+
When prompted, enter your service principal credentials.
156
156
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.
0 commit comments