Last active
July 28, 2021 13:47
-
-
Save lordlinus/a84d88ecb19e69ea6f6246b584ee4106 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pat_token_config=$(jq -n -c \ | |
--arg ls "$PAT_LIFETIME" \ | |
--arg co "Example Token" \ | |
'{lifetime_seconds: ($ls|tonumber), | |
comment: $co | |
}') | |
# Databricks Auth headers | |
adbGlobalToken=$(az account get-access-token --resource 2ff814a6-3304-4ab8-85cb-cd0e6f879c1d --output json | jq -r .accessToken) | |
azureApiToken=$(az account get-access-token --resource https://management.core.windows.net/ --output json | jq -r .accessToken) | |
# Create Auth header for Databricks | |
authHeader="Authorization: Bearer $adbGlobalToken" | |
adbSPMgmtToken="X-Databricks-Azure-SP-Management-Token:$azureApiToken" | |
adbResourceId="X-Databricks-Azure-Workspace-Resource-Id:$adbId" | |
d_curl() { | |
local db_url=${1:?Must provide an argument} | |
curl -sS -X POST -H "$authHeader" -H "$adbSPMgmtToken" -H "$adbResourceId" --data-binary "@-" $db_url | |
} | |
pat_token_response=$(echo "$pat_token_config" | d_curl "https://${adbWorkspaceUrl}/api/2.0/token/create") | |
PAT_TOKEN=$(echo $pat_token_response | jq -r '.token_value') | |
AZ_SCRIPTS_OUTPUT_PATH=${pat_token_response} | |
echo $pat_token_response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment