Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -14,25 +14,26 @@ cosmos_client = CosmosClient.from_connection_string(COSMOS_CONNECTION_STRING)
|
|
14 |
# Initialize Azure Blob Storage Client
|
15 |
blob_service = BlobServiceClient.from_connection_string(BLOB_STORAGE_CONNECTION_STRING)
|
16 |
|
17 |
-
# Function to
|
18 |
-
def
|
19 |
-
|
20 |
for db_properties in cosmos_client.list_databases():
|
21 |
db_name = db_properties['id']
|
|
|
22 |
database_client = cosmos_client.get_database_client(db_name)
|
|
|
23 |
for container_properties in database_client.list_containers():
|
24 |
container_name = container_properties['id']
|
|
|
25 |
container_client = database_client.get_container_client(container_name)
|
|
|
26 |
items = list(container_client.read_all_items())
|
27 |
-
|
28 |
-
|
29 |
|
30 |
-
#
|
31 |
-
|
32 |
-
|
33 |
-
st.subheader(f"Database: {data['database']}, Container: {data['container']}")
|
34 |
-
for item in data['items']:
|
35 |
-
st.json(item)
|
36 |
|
37 |
# Streamlit UI
|
38 |
st.title('Azure Services Integration with Streamlit')
|
|
|
14 |
# Initialize Azure Blob Storage Client
|
15 |
blob_service = BlobServiceClient.from_connection_string(BLOB_STORAGE_CONNECTION_STRING)
|
16 |
|
17 |
+
# Function to Retrieve and Display Cosmos DB Structure
|
18 |
+
def display_cosmos_db_structure():
|
19 |
+
st.subheader('Azure Cosmos DB Structure')
|
20 |
for db_properties in cosmos_client.list_databases():
|
21 |
db_name = db_properties['id']
|
22 |
+
st.markdown(f"#### Database: {db_name}")
|
23 |
database_client = cosmos_client.get_database_client(db_name)
|
24 |
+
|
25 |
for container_properties in database_client.list_containers():
|
26 |
container_name = container_properties['id']
|
27 |
+
st.markdown(f"- **Container**: {container_name}")
|
28 |
container_client = database_client.get_container_client(container_name)
|
29 |
+
|
30 |
items = list(container_client.read_all_items())
|
31 |
+
for item in items:
|
32 |
+
st.markdown(f" - Item: `{item['id']}`") # Replace 'id' with the appropriate key if different
|
33 |
|
34 |
+
# Button to Trigger Display of Cosmos DB Structure
|
35 |
+
if st.button('Show Cosmos DB Structure'):
|
36 |
+
display_cosmos_db_structure()
|
|
|
|
|
|
|
37 |
|
38 |
# Streamlit UI
|
39 |
st.title('Azure Services Integration with Streamlit')
|