Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare applications for Azure deployment by generating infrastructure code, Dockerfiles, and config files.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/key-vault/sdk.md
1# Key Vault - SDK Patterns23## Node.js45> **Auth:** `DefaultAzureCredential` is for local development. See [auth-best-practices.md](../../auth-best-practices.md) for production patterns.67```javascript8const { SecretClient } = require("@azure/keyvault-secrets");9const { DefaultAzureCredential } = require("@azure/identity");1011const client = new SecretClient(12process.env.KEY_VAULT_URL,13new DefaultAzureCredential()14);1516const secret = await client.getSecret("database-connection-string");17console.log(secret.value);18```1920## Python2122> **Auth:** `DefaultAzureCredential` is for local development. See [auth-best-practices.md](../../auth-best-practices.md) for production patterns.2324```python25from azure.keyvault.secrets import SecretClient26from azure.identity import DefaultAzureCredential2728client = SecretClient(29vault_url=os.environ["KEY_VAULT_URL"],30credential=DefaultAzureCredential()31)3233secret = client.get_secret("database-connection-string")34print(secret.value)35```3637## .NET3839> **Auth:** `DefaultAzureCredential` is for local development. See [auth-best-practices.md](../../auth-best-practices.md) for production patterns.4041```csharp42var client = new SecretClient(43new Uri(Environment.GetEnvironmentVariable("KEY_VAULT_URL")),44new DefaultAzureCredential()45);4647KeyVaultSecret secret = await client.GetSecretAsync("database-connection-string");48Console.WriteLine(secret.Value);49```5051## Event Grid Integration (Expiry Notifications)5253```bicep54resource kvEventSubscription 'Microsoft.EventGrid/eventSubscriptions@2023-12-15-preview' = {55name: 'secret-expiry-notification'56scope: keyVault57properties: {58destination: {59endpointType: 'WebHook'60properties: {61endpointUrl: 'https://my-api.example.com/secret-rotation'62}63}64filter: {65includedEventTypes: [66'Microsoft.KeyVault.SecretNearExpiry'67'Microsoft.KeyVault.SecretExpired'68]69}70}71}72```73