@@ -86,6 +86,7 @@ This section contains code snippets covering common tasks:
8686* [ Update an existing key] ( #update-an-existing-key )
8787* [ Delete a key] ( #delete-a-key )
8888* [ Configure automatic key rotation] ( #configure-automatic-key-rotation )
89+ * [ Register external keys] ( #register-external-keys-managed-hsm-only )
8990* [ List keys] ( #list-keys )
9091* [ Perform cryptographic operations] ( #cryptographic-operations )
9192* [ Async API] ( #async-api )
@@ -204,6 +205,29 @@ print(f"Rotated the key on-demand; new version is {rotated_key.properties.versio
204205
205206<!-- END SNIPPET -->
206207
208+ ### Register external keys (Managed HSM only)
209+ [ create_external_key] ( https://aka.ms/azsdk/python/keyvault-keys/docs#azure.keyvault.keys.KeyClient.create_external_key )
210+ registers an external key with a Managed HSM that is configured to use External Key Management (EKM). The external HSM
211+ owns the key material; the Managed HSM stores only a reference to the key.
212+
213+ > ** NOTE:** External keys are only supported on Managed HSM, not regular Key Vault. The Managed HSM must be configured
214+ > with an external HSM source.
215+
216+ ``` python
217+ from azure.identity import DefaultAzureCredential
218+ from azure.keyvault.keys import ExternalKey, KeyClient
219+
220+ credential = DefaultAzureCredential()
221+
222+ key_client = KeyClient(vault_url = " https://my-managed-hsm.managedhsm.azure.net/" , credential = credential)
223+
224+ external_key = ExternalKey(id = " external-key-reference-id" )
225+ key = key_client.create_external_key(" external-key-name" , external_key = external_key)
226+
227+ print (key.name)
228+ print (key.properties.external_key.id)
229+ ```
230+
207231### List keys
208232[ list_properties_of_keys] ( https://aka.ms/azsdk/python/keyvault-keys/docs#azure.keyvault.keys.KeyClient.list_properties_of_keys )
209233lists the properties of all of the keys in the client's vault.
0 commit comments