I am trying to do the End to End implementation of Databricks in CI/CD integration for
Ex: Creation of Cluster , Install libraries and other things using Rest API
So for this we need Domain(Workspace URL) and Token(Access Token) of workspace
How can I get the workspace url and access token by automatically so I can use them in the REST API code using python.
For ex:
This the task for create cluster in release pipeline
def cluster_create():
response = requests.post(
'https://%s/api/2.0/clusters/create' % (DOMAIN),
headers={'Authorization': 'Bearer %s' % TOKEN},
json={
"cluster_name": "cluster",
"spark_version": "7.3.x-scala2.12",
"node_type_id": "Standard_DS3_v2",
"autotermination_minutes": 10,
"autoscale" : {
"min_workers": 1,
"max_workers": 3
}
}
)
if response.status_code == 200:
print(response.json()['cluster_id'])
os.environ["DBRKS_CLUSTER_ID"] = response.json()["cluster_id"]
return response.json()['cluster_id']
else:
print("Error launching cluster: %s: %s" %
(response.json()["error_code"], response.json()["message"]))
Steps:
- In Build pipeline I am creating a data brick workspace with ARM template.
- This is the function I will be using in the release pipeline for creating cluster.
Once I created the Data Bricks workspace How to get Domain or Token in release pipeline to replace the variables in create cluster task automatically for continuous integration and continuous development