Public/Export-DatabricksFolder.ps1
<#
.SYNOPSIS Pulls the contents of a Databricks folder (and subfolders) locally so that they can be committed to a repo .DESCRIPTION Pulls the contents of a Databricks folder (and subfolders) locally so that they can be committed to a repo .PARAMETER BearerToken Your Databricks Bearer token to authenticate to your workspace (see User Settings in Datatbricks WebUI) .PARAMETER Region Azure Region - must match the URL of your Databricks workspace, example northeurope .PARAMETER ExportPath The Databricks folder to export, for example /Shared or /Users/simon@datathirst.net/myfolder - must start with / .PARAMETER LocalOutputPath Path to your repo/local you would like to export the scripts to .EXAMPLE PS C:\> Export-DatabricksFolder -ExportPath $ExportPath -BearerToken $BearerToken -Region $Region -LocalOutputPath $LocalOutputPath -Verbose .NOTES Author: Simon D'Morias / Data Thirst Ltd #> Function Export-DatabricksFolder { [cmdletbinding()] param ( [parameter(Mandatory=$true)][string]$BearerToken, [parameter(Mandatory=$true)][string]$Region, [parameter(Mandatory=$true)][string]$ExportPath, [parameter(Mandatory=$false)][string]$LocalOutputPath ) if ($LocalOutputPath -ne [System.IO.Path]::GetFullPath($LocalOutputPath)){ $LocalOutputPath = Join-Path (Get-Location) $LocalOutputPath } [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $InternalBearerToken = Format-BearerToken($BearerToken) $Region = $Region.Replace(" ","") $outJSON = Get-FolderContents $ExportPath $Region $InternalBearerToken Get-Notebooks $outJSON $ExportPath $Region $InternalBearerToken $LocalOutputPath } |