Spaces:
Sleeping
Sleeping
Update app.py
Browse files13 unmodified lines1415161718192021222324252627282930313233343536373813 unmodified lines# Initialize Azure Blob Storage Clientblob_service = BlobServiceClient.from_connection_string(BLOB_STORAGE_CONNECTION_STRING)# Function to Get Databases, Containers, and Itemsdef get_databases_containers_and_items():all_data = []for db_properties in cosmos_client.list_databases():db_name = db_properties['id']database_client = cosmos_client.get_database_client(db_name)for container_properties in database_client.list_containers():container_name = container_properties['id']container_client = database_client.get_container_client(container_name)items = list(container_client.read_all_items())all_data.append({'database': db_name, 'container': container_name, 'items': items})return all_data# Displaying the Dataall_data = get_databases_containers_and_items()for data in all_data:st.subheader(f"Database: {data['database']}, Container: {data['container']}")for item in data['items']:st.json(item)# Streamlit UIst.title('Azure Services Integration with Streamlit')13 unmodified lines141516171819202122232425262728293031323334353637383913 unmodified lines# Initialize Azure Blob Storage Clientblob_service = BlobServiceClient.from_connection_string(BLOB_STORAGE_CONNECTION_STRING)# Function to Retrieve and Display Cosmos DB Structuredef display_cosmos_db_structure():st.subheader('Azure Cosmos DB Structure')for db_properties in cosmos_client.list_databases():db_name = db_properties['id']st.markdown(f"#### Database: {db_name}")database_client = cosmos_client.get_database_client(db_name)for container_properties in database_client.list_containers():container_name = container_properties['id']st.markdown(f"- **Container**: {container_name}")container_client = database_client.get_container_client(container_name)items = list(container_client.read_all_items())for item in items:st.markdown(f" - Item: `{item['id']}`") # Replace 'id' with the appropriate key if different# Button to Trigger Display of Cosmos DB Structureif st.button('Show Cosmos DB Structure'):display_cosmos_db_structure()# Streamlit UIst.title('Azure Services Integration with Streamlit')
app.py+12-11