Skip to main content

keys

Creates, updates, deletes, gets or lists a keys resource.

Overview

Namekeys
TypeResource
Idazure.key_vault.keys

Fields

The following fields are returned by SELECT queries:

NameDatatypeDescription
idstringFully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}.
namestringThe name of the resource.
attributesobjectThe attributes of the key.
curveNamestringThe elliptic curve name. For valid values, see JsonWebKeyCurveName. Default for EC and EC-HSM keys is P-256. Known values are: "P-256", "P-384", "P-521", and "P-256K". (P-256, P-384, P-521, P-256K)
keyOpsarray:vartype key_ops: list[str or ~azure.mgmt.keyvault.models.JsonWebKeyOperation]
keySizeintegerThe key size in bits. For example: 2048, 3072, or 4096 for RSA. Default for RSA and RSA-HSM keys is 2048. Exception made for bring your own key (BYOK), key exchange keys default to 4096.
keyUristringThe URI to retrieve the current version of the key.
keyUriWithVersionstringThe URI to retrieve the specific version of the key.
ktystringThe type of the key. For valid values, see JsonWebKeyType. Known values are: "EC", "EC-HSM", "RSA", and "RSA-HSM". (EC, EC-HSM, RSA, RSA-HSM)
locationstringThe supported Azure location where the managed HSM Pool should be created.
release_policyobjectKey release policy in response. It will be used for both output and input. Omitted if empty.
rotationPolicyobjectKey rotation policy in response. It will be used for both output and input. Omitted if empty.
systemDataobjectAzure Resource Manager metadata containing createdBy and modifiedBy information.
tagsobjectResource tags.
typestringThe type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts".

Methods

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
get_versionselectresource_group_name, vault_name, key_name, key_version, subscription_idGets the specified version of the specified key in the specified key vault.
getselectresource_group_name, vault_name, key_name, subscription_idGets the current version of the specified key from the specified key vault.
listselectresource_group_name, vault_name, subscription_idLists the keys in the specified key vault.
create_if_not_existexecresource_group_name, vault_name, key_name, subscription_id, propertiesCreates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys.
list_versionsexecresource_group_name, vault_name, key_name, subscription_idLists the keys in the specified key vault.

Parameters

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
key_namestringThe name of the key version to be retrieved. Required.
key_versionstringThe version of the key to be retrieved. Required.
resource_group_namestringThe name of the resource group. The name is case insensitive. Required.
subscription_idstring
vault_namestringThe name of the vault which contains the key version to be retrieved. Required.

SELECT examples

Gets the specified version of the specified key in the specified key vault.

SELECT
id,
name,
attributes,
curveName,
keyOps,
keySize,
keyUri,
keyUriWithVersion,
kty,
location,
release_policy,
rotationPolicy,
systemData,
tags,
type
FROM azure.key_vault.keys
WHERE resource_group_name = '{{ resource_group_name }}' -- required
AND vault_name = '{{ vault_name }}' -- required
AND key_name = '{{ key_name }}' -- required
AND key_version = '{{ key_version }}' -- required
AND subscription_id = '{{ subscription_id }}' -- required
;

Lifecycle Methods

Creates the first version of a new key if it does not exist. If it already exists, then the existing key is returned without any write operations being performed. This API does not create subsequent versions, and does not update existing keys.

EXEC azure.key_vault.keys.create_if_not_exist 
@resource_group_name='{{ resource_group_name }}' --required,
@vault_name='{{ vault_name }}' --required,
@key_name='{{ key_name }}' --required,
@subscription_id='{{ subscription_id }}' --required
@@json=
'{
"tags": "{{ tags }}",
"properties": "{{ properties }}"
}'
;