Azure.Security.KeyVault.Keys (.NET)
Generate Azure Key Vault key code
Developers struggle with Azure Key Vault key management APIs and secure cryptographic practices. This skill provides ready-to-use .NET code snippets, best practices, and implementation guidance for storing, retrieving, and managing cryptographic keys in Azure Key Vault.
Download the skill ZIP
Upload in Claude
Go to Settings → Capabilities → Skills → Upload skill
Toggle on and start using
Test it
Using "Azure.Security.KeyVault.Keys (.NET)". Create a new RSA key in Azure Key Vault with 2048-bit size
Expected outcome:
```csharp
using Azure.Identity;
using Azure.Security.KeyVault.Keys;
var keyClient = new KeyClient(
new Uri("https://myvault.vault.azure.net/"),
new DefaultAzureCredential());
var createKeyOptions = new CreateRsaKeyOptions("my-rsa-key")
{
KeySize = 2048,
ExpiresOn = DateTimeOffset.Now.AddYears(1)
};
KeyVaultKey key = await keyClient.CreateRsaKeyAsync(createKeyOptions);
Console.WriteLine($"Created key: {key.Name}");
```
Using "Azure.Security.KeyVault.Keys (.NET)". Set up automatic key rotation
Expected outcome:
```csharp
var rotationPolicy = new KeyRotationPolicy
{
LifetimeActions =
{
new KeyLifetimeAction
{
Action = KeyRotationAction.Notify,
TimeBeforeExpiry = TimeSpan.FromDays(30)
}
}
};
await keyClient.UpdateKeyRotationPolicyAsync("my-key", rotationPolicy);
```
Security Audit
SafePrompt-only skill with no executable code. Static analysis scanned 0 files and detected 0 potential security issues. Risk score: 0/100. This skill provides guidance and code generation templates for Azure Key Vault key operations using the official Azure SDK for .NET.
Quality Score
What You Can Build
Generate key creation code
Create new cryptographic keys in Azure Key Vault with custom key properties
Implement key rotation
Set up automated key rotation with rotation policies and notifications
Backup and restore keys
Export and import keys securely for disaster recovery scenarios
Try These Prompts
Show me how to create a new RSA key in Azure Key Vault using the Azure SDK for .NET. Include code for setting key size and expiration.
How do I retrieve an existing key from Azure Key Vault and use it for encryption in my .NET application?
Configure automatic key rotation for a key in Azure Key Vault. Show how to set rotation policy and lifetime actions.
Generate code to backup a key to a secure location and restore it when needed. Include error handling.
Best Practices
- Use Azure Identity with Managed Identity in production environments to avoid storing credentials
- Set appropriate expiration times for keys and implement regular rotation policies
- Use separate Key Vaults for different environments (dev, staging, production)
Avoid
- Storing Key Vault URLs or credential information in source code
- Granting excessive permissions to key operations beyond what is needed
- Skipping error handling when interacting with Key Vault operations