Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from azure.cosmos import CosmosClient
|
| 3 |
from azure.storage.blob import BlobServiceClient
|
| 4 |
import requests
|
|
|
|
| 5 |
|
| 6 |
-
# Azure
|
| 7 |
-
cosmos_client = CosmosClient('<your_cosmos_account_url>', credential=
|
| 8 |
blob_service = BlobServiceClient.from_connection_string('<your_blob_storage_connection_string>')
|
| 9 |
|
| 10 |
# Streamlit UI
|
| 11 |
-
st.title('Azure Services
|
| 12 |
|
| 13 |
# Azure Cosmos DB - CRUD Operations
|
| 14 |
st.subheader('Azure Cosmos DB - CRUD Operations')
|
|
@@ -18,12 +19,12 @@ item_id = st.text_input("Item ID (for Read, Update, Delete)")
|
|
| 18 |
item_data = st.text_area("Item Data (JSON format, for Create and Update)")
|
| 19 |
|
| 20 |
if st.button('Create Item in Cosmos DB'):
|
| 21 |
-
container = cosmos_client.get_container_client(
|
| 22 |
container.create_item(item_data)
|
| 23 |
|
| 24 |
if st.button('Read Item from Cosmos DB'):
|
| 25 |
-
container = cosmos_client.get_container_client(
|
| 26 |
-
item = container.read_item(item_id, partition_key=item_id)
|
| 27 |
st.json(item)
|
| 28 |
|
| 29 |
# Azure Blob Storage - Upload/Download
|
|
@@ -38,6 +39,8 @@ if blob_file is not None and st.button('Upload to Blob'):
|
|
| 38 |
# Azure Functions - Trigger
|
| 39 |
st.subheader('Azure Functions - Trigger')
|
| 40 |
function_url = st.text_input('Function URL')
|
|
|
|
| 41 |
if st.button('Call Azure Function'):
|
| 42 |
response = requests.get(function_url)
|
| 43 |
st.write('Function Response:', response.text)
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from azure.cosmos import CosmosClient, PartitionKey
|
| 3 |
from azure.storage.blob import BlobServiceClient
|
| 4 |
import requests
|
| 5 |
+
from azure.identity import DefaultAzureCredential
|
| 6 |
|
| 7 |
+
# Initialize Azure Cosmos DB Client
|
| 8 |
+
cosmos_client = CosmosClient('<your_cosmos_account_url>', credential=DefaultAzureCredential())
|
| 9 |
blob_service = BlobServiceClient.from_connection_string('<your_blob_storage_connection_string>')
|
| 10 |
|
| 11 |
# Streamlit UI
|
| 12 |
+
st.title('Azure Services Integration with Streamlit')
|
| 13 |
|
| 14 |
# Azure Cosmos DB - CRUD Operations
|
| 15 |
st.subheader('Azure Cosmos DB - CRUD Operations')
|
|
|
|
| 19 |
item_data = st.text_area("Item Data (JSON format, for Create and Update)")
|
| 20 |
|
| 21 |
if st.button('Create Item in Cosmos DB'):
|
| 22 |
+
container = cosmos_client.get_database_client(cosmos_db).get_container_client(cosmos_container)
|
| 23 |
container.create_item(item_data)
|
| 24 |
|
| 25 |
if st.button('Read Item from Cosmos DB'):
|
| 26 |
+
container = cosmos_client.get_database_client(cosmos_db).get_container_client(cosmos_container)
|
| 27 |
+
item = container.read_item(item_id, partition_key=PartitionKey(item_id))
|
| 28 |
st.json(item)
|
| 29 |
|
| 30 |
# Azure Blob Storage - Upload/Download
|
|
|
|
| 39 |
# Azure Functions - Trigger
|
| 40 |
st.subheader('Azure Functions - Trigger')
|
| 41 |
function_url = st.text_input('Function URL')
|
| 42 |
+
|
| 43 |
if st.button('Call Azure Function'):
|
| 44 |
response = requests.get(function_url)
|
| 45 |
st.write('Function Response:', response.text)
|
| 46 |
+
|