azure-keyvault-py non-hero scenarios
These scenarios are intentionally separate from hero flows in SKILL.md.
They cover secondary/advanced patterns typically used after the primary end-to-end path is working.
Async Clients
from azure.identity.aio import DefaultAzureCredential
from azure.keyvault.secrets.aio import SecretClient
async def get_secret():
async with DefaultAzureCredential() as credential:
async with SecretClient(vault_url=vault_url, credential=credential) as client:
secret = await client.get_secret("my-secret")
print(f"Retrieved secret: {secret.name} (version: {secret.properties.version})")
import asyncio
asyncio.run(get_secret())Error Handling
from azure.core.exceptions import ResourceNotFoundError, HttpResponseError
try:
secret = client.get_secret("nonexistent")
except ResourceNotFoundError:
print("Secret not found")
except HttpResponseError as e:
if e.status_code == 403:
print("Access denied - check RBAC permissions")
raise