Edit

Manage keys in an Azure Managed HSM

Note

Key Vault supports two types of resources: vaults and managed HSMs. This article is about Managed HSM. If you want to learn how to manage a vault, see Quickstart: Create a key vault using the Azure CLI.

For an overview of Managed HSM, see What is Managed HSM?

Prerequisites

An Azure subscription is required. If you don't have one, create a free account before you begin.

You also need:

Note

All the following commands show two usage methods for CLI. One method uses the --hsm-name and --name (for key name) parameters. The other method uses the --id parameter, where you can specify the entire URL including the key name when appropriate. The latter method is useful when the caller (a user or an application) has no read access on the control plane and only restricted access on the data plane.

Some interactions with key material require specific Managed HSM local RBAC permissions. For a full list of built-in Managed HSM local RBAC roles and permissions, see Managed HSM local RBAC built-in roles. To assign these permissions to a user, see Secure access to your managed HSMs.

Create an HSM key

Note

You can't export a key that's generated or imported into Managed HSM. The only exception to the no-export rule is when you create a key with a specific key release policy. This policy allows the key to be exported only to trusted confidential computing environments (secure enclaves) that you explicitly define. This limited export capability is designed for specific secure computing scenarios and isn't the same as a general-purpose key export. For recommended best practices for key portability and durability, see the linked article.

  1. In the Azure portal, navigate to your Managed HSM resource.

  2. In the left menu, under Settings, select Keys.

  3. Select Generate/Import from the Generate/Import/Restore Backup dropdown.

  4. Choose the key type (RSA-HSM, EC-HSM, or oct-HSM), set the key size or curve, name, and permitted operations, then select Create.

    Screenshot of the Keys blade in the Azure portal for a Managed HSM.

View key attributes and tags

  1. In the Azure portal, navigate to your Managed HSM resource.

  2. In the left menu, under Settings, select Keys.

  3. Select the key you want to view. The portal displays the key's attributes, versions, and tags.

List keys

  1. In the Azure portal, navigate to your Managed HSM resource.

  2. In the left menu, under Settings, select Keys. The portal lists all keys in the Managed HSM.

Delete a key

  1. In the Azure portal, navigate to your Managed HSM resource.

  2. In the left menu, under Settings, select Keys.

  3. Select the key you want to delete.

  4. Select Delete, and then confirm.

List deleted keys

  1. In the Azure portal, navigate to your Managed HSM resource.

  2. In the left menu, under Settings, select Keys.

  3. Select Manage deleted keys to view keys in the soft-deleted state.

Recover (undelete) a deleted key

  1. In the Azure portal, navigate to your Managed HSM resource.

  2. In the left menu, under Settings, select Keys, then select Manage deleted keys.

  3. Select the deleted key you want to recover.

  4. Select Recover.

Purge (permanently delete) a key

Note

If the managed HSM has purge protection enabled, the purge operation isn't permitted. The key is automatically purged when the retention period passes.

  1. In the Azure portal, navigate to your Managed HSM resource.

  2. In the left menu, under Settings, select Keys, then select Manage deleted keys.

  3. Select the deleted key you want to purge.

  4. Select Purge, and then confirm.

Warning

This operation permanently deletes your key.

Create a single key backup

Key backup isn't currently available in the Azure portal. Use the Azure CLI or Azure PowerShell.

Restore a single key from backup

  1. In the Azure portal, navigate to your Managed HSM resource.

  2. In the left menu, under Settings, select Keys.

  3. Select Generate/Import/Restore Backup and choose Restore key from backup.

  4. Browse to and select the backup file, then select Restore.

Import a key from a file

Key import isn't currently available in the Azure portal. Use the Azure CLI or Azure PowerShell.

To import a key from your on-premises HSM to managed HSM, see Import HSM-protected keys to Managed HSM (BYOK).

Next steps