Spaces:
Build error
Build error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from azure.identity import DefaultAzureCredential
|
3 |
+
from azure.keyvault.secrets import SecretClient
|
4 |
+
|
5 |
+
# Define Azure Key Vault and Secret Name
|
6 |
+
azure_key_vault_url = "https://your-keyvault-name.vault.azure.net/"
|
7 |
+
secret_name = "your-secret-name"
|
8 |
+
|
9 |
+
# Initialize Azure credential
|
10 |
+
credential = DefaultAzureCredential()
|
11 |
+
|
12 |
+
# Initialize Secret Client
|
13 |
+
secret_client = SecretClient(vault_url=azure_key_vault_url, credential=credential)
|
14 |
+
|
15 |
+
# Streamlit App
|
16 |
+
st.title("Azure Authentication Example")
|
17 |
+
|
18 |
+
# Authenticate to Azure Key Vault
|
19 |
+
try:
|
20 |
+
secret_value = secret_client.get_secret(secret_name).value
|
21 |
+
st.success("Successfully authenticated to Azure Key Vault.")
|
22 |
+
except Exception as e:
|
23 |
+
st.error(f"Authentication failed: {str(e)}")
|
24 |
+
|
25 |
+
# Display secret value
|
26 |
+
if secret_value:
|
27 |
+
st.write(f"The secret value from Azure Key Vault is: {secret_value}")
|
28 |
+
|
29 |
+
# Optional: You can add more Streamlit components and functionality as needed
|