An Apache Spark-based analytics platform optimized for Azure.
Hi ,
Thanks for reaching out to Microsoft Q&A.
To upload .txt and .sh files to a Databricks Workspace folder via Azure DevOps pipeline, you cannot use the DBFS CLI for Workspace uploads. Instead, use the Databricks REST API or the Databricks CLI (v0.205+) with workspace commands.
Preferred Approach: Use Databricks CLI with workspace API
- Install Databricks CLI (v0.205 or later) in your pipeline:
Make sure your pipeline agent installs the latest CLI and sets up authentication. Use Databricks PAT (Personal Access Token) as DATABRICKS_TOKEN.
- script: | pip install databricks-cli --upgrade databricks configure --token <<EOF $(DATABRICKS_HOST) $(DATABRICKS_TOKEN) EOF displayName: 'Install and Configure Databricks CLI'
2.Upload files to Workspace path
Example: Upload a shell script to /Workspace/Shared/init/init.sh. Make sure init.sh and myfile.txt are in your repository or available in the working directory.
- script: | databricks workspace mkdirs /Shared/init databricks workspace import init.sh /Shared/init/init.sh --format AUTO --language SHELL databricks workspace import myfile.txt /Shared/init/myfile.txt --format AUTO --language TEXT displayName: 'Upload files to Databricks Workspace'
- Workspace path is not the same as DBFS. Init scripts in Workspace can be referred using the path:
/Workspace/Shared/init/init.sh - Use workspace path when cluster init script source is Workspace in UI or JSON.
Validate: Cluster JSON Snippet (Workspace-based init script). You can use this in your cluster definition (via REST API or Terraform) to attach the init script.
"init_scripts": [
{
"workspace": {
"destination": "/Shared/init/init.sh"
}
}
]
Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.