Edit

Share via


Azure Key Vault developer's guide

Azure Key Vault is a cloud service that provides secure storage and management of cryptographic keys, secrets, and certificates. This guide helps developers integrate Key Vault into their applications.

Overview

Azure Key Vault enables you to:

  • Secure storage: Protect keys, secrets, and certificates without writing custom security code.
  • Simplified key management: Centralize cryptographic operations and key lifecycle management.
  • Customer-owned keys: Allow customers to manage their own keys while you focus on core application features.
  • External key management: Use keys for signing and encryption while keeping them external to your application.

For general information on Azure Key Vault, see About Azure Key Vault.

Developer scenarios

Common developer tasks with Key Vault include:

  • Store and retrieve secrets: Manage connection strings, passwords, API keys, and SAS tokens securely. For more information, see About secrets.
  • Use keys for encryption and signing: Perform cryptographic operations without exposing key material to your application. For more information, see About keys.
  • Manage certificates: Automate certificate provisioning, renewal, and deployment for SSL/TLS. For more information, see About certificates.

Public previews

We periodically release public previews of new Key Vault features. To try preview features and provide feedback, contact us at azurekeyvault@microsoft.com. For information about the latest features and updates, see What's new in Azure Key Vault.

Create and manage key vaults

Key Vault uses a two-plane access model:

Use the predefined Key Vault Contributor role to grant management access to Key Vault resources. For more information on authentication and authorization, see Authentication in Azure Key Vault.

Network security

Reduce network exposure by configuring private endpoints, firewalls, or service endpoints. For comprehensive network security guidance including configuration options from most to least restrictive, see Secure your Azure Key Vault: Network Security and Configure Azure Key Vault networking settings.

APIs and SDKs for key vault management

The following table lists SDKs and quickstarts for managing Key Vault resources (control plane operations). For the latest versions and installation instructions, see Client libraries.

Azure CLI PowerShell REST API Resource Manager .NET Python Java JavaScript
Reference
Quickstart
Reference
Quickstart
Reference Reference
Quickstart
Reference Reference Reference Reference

Authenticate to Key Vault in code

Key Vault uses Microsoft Entra authentication, which requires a Microsoft Entra security principal to grant access. A Microsoft Entra security principal can be a user, an application service principal, a managed identity for Azure resources, or a group of any of these types.

Authentication best practices

For applications deployed to Azure, use managed identities to eliminate the need for storing credentials in code. For detailed authentication guidance and security principal recommendations for different environments (production, development, local), see Authentication in Azure Key Vault and Secure your Azure Key Vault.

Azure Identity client libraries

The preceding authentication scenarios are supported by the Azure Identity client library and integrated with Key Vault SDKs. You can use the Azure Identity client library across environments and platforms without changing your code. The library automatically retrieves authentication tokens from users who are signed in to Azure user through the Azure CLI, Visual Studio, Visual Studio Code, and other means.

For more information about the Azure Identity client library, see:

.NET Python Java JavaScript
Azure Identity SDK .NET Azure Identity SDK Python Azure Identity SDK Java Azure Identity SDK JavaScript

Note

We recommended App Authentication library for Key Vault .NET SDK version 3, but it's now deprecated. To migrate to Key Vault .NET SDK version 4, follow the AppAuthentication to Azure.Identity migration guidance.

For tutorials on how to authenticate to Key Vault in applications, see:

Manage keys, certificates, and secrets

Note

SDKs for .NET, Python, Java, JavaScript, PowerShell, and the Azure CLI are part of the Key Vault feature release process through public preview and general availability with Key Vault service team support. Other SDK clients for Key Vault are available, but they are built and supported by individual SDK teams over GitHub and released in their teams schedule. For the latest SDK versions and installation packages, see Client libraries.

The data plane controls access to keys, certificates, and secrets. You can use Azure RBAC with Key Vault for access control through the data plane.

APIs and SDKs for keys

The following table lists SDKs and quickstarts for working with keys (data plane operations). For more information about keys, see About keys.

Azure CLI PowerShell REST API Resource Manager .NET Python Java JavaScript
Reference
Quickstart
Reference
Quickstart
Reference Reference
Quickstart
Reference
Quickstart
Reference
Quickstart
Reference
Quickstart
Reference
Quickstart

Other Libraries

Cryptography client for Key Vault and Managed HSM

This module provides a cryptography client for the Azure Key Vault Keys client module for Go.

Note

This project is not supported by the Azure SDK team, but does align with the cryptography clients in other supported languages.

Language Reference
Go Reference

APIs and SDKs for certificates

The following table lists SDKs and quickstarts for working with certificates (data plane operations). For more information about certificates, see About certificates.

Azure CLI PowerShell REST API Resource Manager .NET Python Java JavaScript
Reference
Quickstart
Reference
Quickstart
Reference N/A Reference
Quickstart
Reference
Quickstart
Reference
Quickstart
Reference
Quickstart

APIs and SDKs for secrets

The following table lists SDKs and quickstarts for working with secrets (data plane operations). For more information about secrets, see About secrets.

Azure CLI PowerShell REST API Resource Manager .NET Python Java JavaScript
Reference
Quickstart
Reference
Quickstart
Reference Reference
Quickstart
Reference
Quickstart
Reference
Quickstart
Reference
Quickstart
Reference
Quickstart

Usage of secrets

Use Azure Key Vault to store only secrets for your application. Examples of secrets that should be stored in Key Vault include:

  • Client application secrets
  • Connection strings
  • Passwords
  • Shared access keys
  • SSH keys

Any secret-related information, like usernames and application IDs, can be stored as a tag in a secret. For any other sensitive configuration settings, you should use Azure App Configuration.

For installation packages and source code, see Client libraries.

Use Key Vault in applications

To take advantage of the most recent features in Key Vault, we recommend that you use the available Key Vault SDKs for using secrets, certificates, and keys in your application. The Key Vault SDKs and REST API are updated as new features are released for the product, and they follow best practices and guidelines.

For basic scenarios, there are other libraries and integration solutions for simplified usage, with support provided by Microsoft partners or open-source communities.

For certificates, you can use:

For secrets, you can use:

Code examples

For complete examples of using Key Vault with applications, see Azure Key Vault code samples.

Task-specific guidance

The following articles and scenarios provide task-specific guidance for working with Azure Key Vault:

Integration with Key Vault

The following services and scenarios use or integrate with Key Vault:

  • Encryption at rest allows the encoding (encryption) of data when it's persisted. Data encryption keys are often encrypted with a key encryption key in Azure Key Vault to further limit access.
  • Azure Information Protection allows you to manage your own tenant key. For example, instead of Microsoft managing your tenant key (the default), you can manage your own tenant key to comply with specific regulations that apply to your organization. Managing your own tenant key is also called bring your own key (BYOK).
  • Azure Private Link enables you to access Azure services (for example, Azure Key Vault, Azure Storage, and Azure Cosmos DB) and Azure-hosted customer/partner services over a private endpoint in your virtual network.
  • Key Vault integration with Azure Event Grid allows users to be notified when the status of a secret stored in Key Vault has changed. You can distribute new versions of secrets to applications or rotate near-expiration secrets to prevent outages.
  • Protect your Azure DevOps secrets from unwanted access in Key Vault.
  • Use secrets stored in Key Vault to connect to Azure Storage from Azure Databricks.
  • Configure and run the Azure Key Vault provider for the Secrets Store CSI driver on Kubernetes.

Disaster recovery and business continuity

Key Vault provides built-in disaster recovery with automatic regional replication. For production deployments, enable soft delete and purge protection, and implement regular backups. For more information, see Azure Key Vault availability and redundancy, Azure Key Vault recovery management, and Azure Key Vault backup.

Performance and scalability

When developing applications that use Key Vault, consider the following performance and scalability best practices:

  • Service limits: Key Vault has service limits for transactions per vault per region. Exceeding these limits results in throttling. For more information, see Azure Key Vault service limits.
  • Throttling guidance: Implement retry logic with exponential backoff to handle throttling responses. For more information, see Azure Key Vault throttling guidance.
  • Caching: Cache secrets and certificates in your application to reduce calls to Key Vault and improve performance.
  • Connection management: Reuse HTTP connections to Key Vault when possible to reduce latency and improve performance.

Monitoring and logging

Enable logging and monitoring for security, compliance, and troubleshooting. Configure diagnostic settings, Event Grid notifications, and alerts for critical events. For detailed guidance, see Monitor Azure Key Vault, Azure Key Vault logging, Monitoring Key Vault with Azure Event Grid, and Secure your Azure Key Vault: Logging and Threat Detection.

Common parameters and request patterns

When working with the Key Vault REST API, understanding common parameters and request/response patterns is helpful:

Troubleshooting

For help resolving common issues:

Security best practices

For comprehensive security guidance including identity and access management, data protection, compliance, governance, and backup strategies, see Secure your Azure Key Vault.

Additional resources

Key Vault concepts

Management and operations

Community and support