- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2023 08:44 AM
Here is a sample in powershell and Azure which checks if it is already configured - if not then it sets the git config for the user - you would just want to tweak it to change the pat if needed:
"Getting current git-credentials..."
$uri = $databricksUrl + "/api/2.0/git-credentials"
$headers = @{
"Authorization" = "Bearer $databricksToken"
"X-Databricks-Azure-SP-Management-Token" = $azToken
"X-Databricks-Azure-Workspace-Resource-Id" = $wsId
}
"Headers: " +$headers
"Checking if git-config already exists."
$gitconfig = Invoke-RestMethod -Uri $uri -Headers $headers
if (![String]::IsNullOrWhitespace($gitconfig)) {
"Git config already exists"
} else {
$body = '{
"personal_access_token": $gitPat,
"git_username": $gitUsername,
"git_provider": "gitHub"
}'
$gitconfig = Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body -ContentType "application/json"
$gitconfig
}