cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to call Cluster API and start cluster from within Databricks Notebook?

Kaniz
Community Manager
Community Manager
 
1 REPLY 1

Hubert-Dudek
Esteemed Contributor III

There are API endpoints to manage clusters. Official documentation: https://docs.databricks.com/dev-tools/api/latest/clusters.html. Here is example code which can be run from notebook:

ctx = dbutils.notebook.entry_point.getDbutils().notebook().getContext()
host = ctx.tags().get("browserHostName").get()
token = ctx.apiToken().get()
cluster_id =  "new_cluster_id"
 
requests.post(
    f'https://{host}/api/2.0/clusters/get', 
    json = {'cluster_id': cluster_id}, 
    headers = {'Authorization': f'Bearer {token}'}
)

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.