llm-shield-cloud-azure
Azure cloud integrations for LLM Shield - Key Vault, Blob Storage, and Azure Monitor.
Overview
Production-ready Azure implementations of cloud abstraction traits:
- Azure Key Vault - Secure secret storage with automatic caching
- Azure Blob Storage - Object storage for models and results
- Azure Monitor Metrics - Application metrics and monitoring
- Azure Monitor Logs - Structured logging via Log Analytics
Installation
[]
= "0.1"
= "0.1"
= { = "1.35", = ["full"] }
Quick Start
Key Vault
use AzureKeyVault;
use CloudSecretManager;
async
Blob Storage
use AzureBlobStorage;
use CloudStorage;
async
Azure Monitor
use AzureMonitorMetrics;
use ;
use HashMap;
async
Configuration
cloud:
provider: azure
azure:
key_vault:
vault_url: https://my-vault.vault.azure.net
cache_ttl_seconds: 300
storage:
account_name: mystorageaccount
container_name: models
monitor:
workspace_id: workspace-id
shared_key: shared-key
log_type: LLMShieldLog
Azure Credentials
Uses DefaultAzureCredential which tries:
- Environment variables: AZURE_TENANT_ID, AZURE_CLIENT_ID, AZURE_CLIENT_SECRET
- Azure CLI:
az logincredentials - Managed Identity: For Azure VMs, App Service, Container Apps
Development Setup
# Install Azure CLI
|
# Login
# Set subscription
Production (Managed Identity)
Azure VM:
# Enable system-assigned managed identity
# Get principal ID
PRINCIPAL_ID=
# Assign roles
App Service:
# Enable managed identity
# Assign roles
PRINCIPAL_ID=
Container Apps:
# Enable managed identity
# Assign roles
PRINCIPAL_ID=
RBAC Permissions
See rbac-roles/ for custom role definitions:
key-vault-role.json- Key Vault permissionsstorage-role.json- Blob Storage permissionsmonitor-role.json- Azure Monitor permissionsllm-shield-full-role.json- All permissions (dev/test)
Creating Custom Roles
# Create custom role
# Assign to managed identity
Testing
Unit Tests
Integration Tests
Performance
| Operation | Throughput | Latency (p50) |
|---|---|---|
| Secret fetch (cached) | 100,000/s | <1ms |
| Secret fetch (uncached) | 1,000/s | ~50ms |
| Blob upload (1MB) | 50 MB/s | ~20ms |
| Blob upload (50MB blocks) | 80 MB/s | ~625ms |
| Metrics export (batch) | 1,000/s | ~10ms |
| Logs export (batch) | 10,000/s | ~5ms |
Cost Estimates
Monthly costs (production):
| Service | Usage | Cost |
|---|---|---|
| Key Vault | 10 secrets, 100K ops | ~$3 |
| Blob Storage (LRS) | 100 GB, 1M ops | ~$2 |
| Log Analytics | 50 GB ingested | ~$115 |
| Azure Monitor Metrics | 50 metrics | ~$10 |
| Total | ~$130/month |
Security Best Practices
- Use Managed Identity (no credentials in code)
- Apply least-privilege RBAC roles
- Enable Key Vault soft delete and purge protection
- Use private endpoints for Key Vault and Storage
- Enable Azure Policy for compliance
- Set storage account firewall rules
- Enable diagnostic logging for all services
- Use customer-managed keys (CMK) for encryption
- Enable Azure Defender for Cloud
- Review access regularly with Azure AD PIM
Troubleshooting
Authentication Errors
# Check current authentication
# Check managed identity
Permission Errors
# List role assignments
# Test Key Vault access
# Test Blob Storage access
Resource Not Found
# Verify Key Vault exists
# Verify storage account exists
# Verify container exists
Architecture
┌─────────────────────────────────────┐
│ LLM Shield Application │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ llm-shield-cloud (traits) │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ llm-shield-cloud-azure (impl) │
│ - AzureKeyVault │
│ - AzureBlobStorage │
│ - AzureMonitorMetrics/Logs │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Azure SDK for Rust │
│ - azure_security_keyvault │
│ - azure_storage_blobs │
│ - reqwest (Monitor API) │
└─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────┐
│ Azure Services │
│ - Key Vault │
│ - Blob Storage │
│ - Azure Monitor │
└─────────────────────────────────────┘
License
MIT OR Apache-2.0
Related Crates
llm-shield-cloud- Cloud abstraction traitsllm-shield-cloud-aws- AWS integrationsllm-shield-cloud-gcp- GCP integrations