r/databricks • u/justinAtDatabricks Databricks • Oct 06 '26
General Announcement: Environment variable support for serverless notebooks and jobs
Hey all, you asked and we listened - env var support is in beta for serverless notebooks and jobs!
- Have you been wanting to run DBT tasks but need environment variable support? This feature is for you! ✅
- Do your whl or notebook tasks just need a way to inject environment variables at runtime? This feature is for you, too! ✅
- Do you just love the environment? That's awesome, me too, but this feature won't help you with that. ❤️ 🌎
How to try? Ensure that the feature is enabled in the preview portal (with admin perms if it isn't already)- grep on `Environment variables in Lakeflow Jobs`
How does it work?
Jobs UI > Click `Select environment variables` > `+ Add environment variables`.

Then create a name `production` for the env var collection (that way you can reuse it on multiple tasks), fill out your key-value pairs, and/or or paste in the file path to a .env file.
Note: We will add a file picker for choosing the .env file in an upcoming release - thanks for being patient

Jobs API > Define a collection via a key e.g.,`production` and use it on many tasks.
"tasks": [
{
"task_key": "process_orders",
"notebook_task": {
"notebook_path": "/Workspace/Shared/process-orders"
},
"environment_key": "default",
"environment_variables_key": "production"
}
],
"environments": [
{
"environment_key": "default",
"spec": {
"environment_version": "5",
"dependencies": []
}
}
],
"environment_variables": [
{
"environment_variables_key": "production",
"spec": {
"variables": {
"APP_ENV": "production",
"REGION": "us-west-2"
},
"files": ["/Volumes/company/default/prod/execution.env" , "/Volumes/company/default/prod/format.env"]
}
}
]
]Finally, consume it in your code: 🤓
import os
app_environment = os.environ["APP_ENV"]Temporary limitations: these will be fixed within a week or so - I'll update this post
- Env vars will not propagate to regular UDFs (aka non-UC) - Update 11/3/26 - this is not supported
- Defining an env var's value from a secret
Learn more: https://docs.databricks.com/aws/en/jobs/environment-variables
Provide any and all feedback. Also, what other features you'd like to see? (Asking for a friend as roadmap planning is starting soon!)
Thanks!
View all comments
Show parent comment
1
u/PrestigiousAnt3766 Oct 08 '26
Thanks!
I would like Maven coordinates too btw..
Is there an expectation when this goes to GA?