Reputation: 1511
We want to generate Azure databrics Access token using Powershell. From the docs, it says that we need a token first (created manually) then we can use the Token API to create the subsequent tokens.
In my situation, we will not have any "manually" created tokens, and we will have to create the first Access token programmatically. Is this possible?
Upvotes: 4
Views: 1720
Reputation: 87069
You can create an initial token using REST API but authenticating using the AAD Token as described in the documentation. Here is an example on how you can do it by acquiring AAD token via az-cli:
$ export DATABRICKS_TOKEN=$(az account get-access-token --resource=2ff814a6-3304-4ab8-85cb-cd0e6f879c1d|jq -r .accessToken)
$ export DATABRICKS_HOST="https://adb-er2323423.9.azuredatabricks.net"
$ curl -s -n -X POST "$DATABRICKS_HOST/api/2.0/token/create" \
--data-raw '{"lifetime_seconds": 100,"comment": "this is an example token"}' \
-H "Authorization: Bearer $DATABRICKS_TOKEN"
{"token_value":"aaaa",
"token_info":{ "token_id":"1312312312","creation_time":1624438106008,
"expiry_time":1624438206008,"comment":"this is an example token"}}
Upvotes: 1
Reputation: 12768
Unfortunately, you cannot create Azure Databricks token programmatically.
You need to create Azure Databricks personal access token manually by going to the Azure Databricks portal.
Even for creating using APIs, initial authentication to this API is the same as for all of the Azure Databricks API endpoints: you must first authenticate as described in Authentication.
Upvotes: 2