cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Community Articles
Dive into a collaborative space where members like YOU can exchange knowledge, tips, and best practices. Join the conversation today and unlock a wealth of collective wisdom to enhance your experience and drive success.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Azure Databricks Streamlit Application - Doubts

RJTECHY210
New Contributor

Hi Databricks community, I am currently tasked with creating a stream lit application with the help of data bricks application feature, I have currently created a lake base instance to sync the delta table located at the unity catalog and I have also created the application using stream lit and connected the lake base instance as backend  and now I got a doubt, Is it possible to start/stop the lake base instance via the stream lit application Ui, if possible what are all the prerequisite access do I need to get in order to trigger lake base instance from my application and any code snippet that I can refer to?

1 REPLY 1

szymon_dybczak
Esteemed Contributor III

Hi @RJTECHY210 ,

Yes, it's possible. You can use python sdk to achieve what you want. Here's a sample code for a reference:

from databricks.sdk import WorkspaceClient
from databricks.sdk.service.database import DatabaseInstance

# Initialize the Workspace client
w = WorkspaceClient()

# Stop a database instance
instance_name = "my-database-instance"
w.database.update_database_instance(
    name=instance_name,
    database_instance=DatabaseInstance(
        name=instance_name,
        stopped=True
    ),
    update_mask="*"
)
print(f"Stopped database instance: {instance_name}")

# Start a database instance
w.database.update_database_instance(
    name=instance_name,
    database_instance=DatabaseInstance(
        name=instance_name,
        stopped=False
    ),
    update_mask="*"
)
print(f"Started database instance: {instance_name}")

Also, don't forget to add proper permission for you databricks apps service principal. To be able to start and stop lakebase instance you need to have can manage permissions:

szymon_dybczak_0-1765046635264.png