Our pipeline logic includes the Add-DatabricksDBFSFile
function to move .sh
file from DevOps repot to DBFS in databricks for later cluster clreation purpose (below code)
Add-DatabricksDBFSFile -BearerToken $ADB_Token -Region $region `
-LocalRootFolder $initFolder -FilePattern "pyodbc.sh" -TargetLocation '/init' -Verbose
New-DatabricksCluster -BearerToken $ADB_Token -Region $region -ClusterName $cname -SparkVersion $csparkV `
-NodeType $cnodeT -MinNumberOfWorkers $cminWorker -MaxNumberOfWorkers $cmaxWorker -AutoTerminationMinutes $cterm `
-InitScripts "dbfs:/init/pyodbc.sh" -UniqueNames -Update
No this is not supported anymore and I need migrate from init scripts on DBFS.
My first attempt was to simply coppy the file from devops repo to already exisitng folder Init
in databricks works with below code.
$initFolder = $PSScriptRoot + 'InitScripts'
$localFilePath = Join-Path -Path $initFolder -ChildPath 'pyodbc.sh'
$databricksInstance = "https://adb-88888888888888.88.azuredatabricks.net"
$workspacePath = '/Workspace/Init/pyodbc.sh'
$fileContent = [System.IO.File]::ReadAllBytes($localFilePath)
$fileBase64 = [Convert]::ToBase64String($fileContent)
$apiUrl = "$databricksInstance/api/2.0/workspace/import"
$body = @{
path = $workspacePath
content = $fileBase64
format = "SOURCE" # The format to specify that this is a plain text/source file
overwrite = $false # Set to true to overwrite any existing file at the destination path
} | ConvertTo-Json
$response = Invoke-RestMethod -Uri $apiUrl -Method POST -Headers @{Authorization = $InternalBearerToken } -Body $body -ContentType "application/json"
Write-Output "Init script writing"
$response
Write-Output "Init script successfully written"
but Im getting this error
Invoke-RestMethod :
{“error_code”:”INVALID_PARAMETER_VALUE”,”message”:”The zip file may
not be valid or may be an unsupported version.”}