Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions sdk/keyvault/azure-keyvault-keys/samples/list_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
print("\n.. Create Key")
rsa_key = client.create_rsa_key("rsaKeyName")
ec_key = client.create_ec_key("ecKeyName")
print("Key with name '{0}' was created of type '{1}'.".format(rsa_key.name, rsa_key.key_type))
print("Key with name '{0}' was created of type '{1}'.".format(ec_key.name, ec_key.key_type))
print(f"Key with name '{rsa_key.name}' was created of type '{rsa_key.key_type}'.")
print(f"Key with name '{ec_key.name}' was created of type '{ec_key.key_type}'.")

# You need to check the type of all the keys in the vault.
# Let's list the keys and print their key types.
Expand All @@ -58,20 +58,20 @@
for key in keys:
retrieved_key = client.get_key(key.name)
print(
"Key with name '{0}' with type '{1}' was found.".format(retrieved_key.name, retrieved_key.key_type)
f"Key with name '{retrieved_key.name}' with type '{retrieved_key.key_type}' was found."
)

# The rsa key size now should now be 3072, default - 2048. So you want to update the key in Key Vault to ensure
# it reflects the new key size. Calling create_rsa_key on an existing key creates a new version of the key in
# the Key Vault with the new key size.
new_key = client.create_rsa_key(rsa_key.name, size=3072)
print("New version was created for Key with name '{0}' with the updated size.".format(new_key.name))
print(f"New version was created for Key with name '{new_key.name}' with the updated size.")

# You should have more than one version of the rsa key at this time. Lets print all the versions of this key.
print("\n.. List versions of a key using its name")
key_versions = client.list_properties_of_key_versions(rsa_key.name)
for key in key_versions:
print("Key '{0}' has version: '{1}'".format(key.name, key.version))
print(f"Key '{key.name}' has version: '{key.version}'")

# Both the rsa key and ec key are not needed anymore. Let's delete those keys.
print("\n.. Delete the created keys...")
Expand All @@ -82,4 +82,4 @@
print("\n.. List deleted keys from the Key Vault (requires soft-delete)")
deleted_keys = client.list_deleted_keys()
for deleted_key in deleted_keys:
print("Key with name '{0}' has recovery id '{1}'".format(deleted_key.name, deleted_key.recovery_id))
print(f"Key with name '{deleted_key.name}' has recovery id '{deleted_key.recovery_id}'")