File size: 936 Bytes
c0bcec9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import streamlit as st
from azure.identity import DefaultAzureCredential
from azure.keyvault.secrets import SecretClient

# Define Azure Key Vault and Secret Name
azure_key_vault_url = "https://your-keyvault-name.vault.azure.net/"
secret_name = "your-secret-name"

# Initialize Azure credential
credential = DefaultAzureCredential()

# Initialize Secret Client
secret_client = SecretClient(vault_url=azure_key_vault_url, credential=credential)

# Streamlit App
st.title("Azure Authentication Example")

# Authenticate to Azure Key Vault
try:
    secret_value = secret_client.get_secret(secret_name).value
    st.success("Successfully authenticated to Azure Key Vault.")
except Exception as e:
    st.error(f"Authentication failed: {str(e)}")

# Display secret value
if secret_value:
    st.write(f"The secret value from Azure Key Vault is: {secret_value}")

# Optional: You can add more Streamlit components and functionality as needed