Skip to content

Commit 79b4bdf

Browse files
authored
Clarify Key Vault client creation instructions (Azure#23594)
* Clarify Key Vault client creation instructions Fixes Azure#23586 * Resolved PR feedback
1 parent 5266d2d commit 79b4bdf

File tree

16 files changed

+44
-43
lines changed

16 files changed

+44
-43
lines changed

sdk/keyvault/Azure.Security.KeyVault.Administration/README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ cryptographic keys for your cloud applications using FIPS 140-2 Level 3 validate
55

66
The Azure Key Vault administration library clients support administrative tasks such as full backup / restore and key-level role-based access control (RBAC).
77

8-
[Source code][admin_client_src] | [Package (NuGet)][admin_client_nuget_package] | [Product documentation][keyvault_docs] | [Samples][admin_client_samples]
8+
[Source code][admin_client_src] | [Package (NuGet)][admin_client_nuget_package] | [Product documentation][managedhsm_docs] | [Samples][admin_client_samples]
99

1010
## Getting started
1111

@@ -24,7 +24,7 @@ See the final two steps in the next section for details on creating the Key Vaul
2424

2525
### Authenticate the client
2626
In order to control permissions to the Key Vault service, you'll need to create an instance of the [KeyVaultAccessControlClient][rbac_client] class.
27-
You need a **vault URL**, which you may see as "DNS Name" in the portal, and **client secret credentials (client id, client secret, tenant id)**
27+
You need a **Managed HSM URL**, which you may see as "DNS Name" in the portal, and **client secret credentials (client id, client secret, tenant id)**
2828
to instantiate a client object.
2929

3030
Client secret credential authentication is being used in this getting started section but you can find more ways to authenticate with
@@ -69,15 +69,15 @@ environment variables. The following example shows a way to do this in Powershel
6969
```
7070
7171
* Create the Managed HSM and grant the above mentioned service principal authorization to perform administrative operations on the Managed HSM
72-
(replace `<your-resource-group-name>` and `<your-key-vault-name>` with your own, unique names and `<your-service-principal-object-id>` with the value from above):
72+
(replace `<your-resource-group-name>` and `<your-managed-hsm-name>` with your own, unique names and `<your-service-principal-object-id>` with the value from above):
7373
```PowerShell
74-
az keyvault create --hsm-name <your-key-vault-name> --resource-group <your-resource-group-name> --administrators <your-service-principal-object-id> --location <your-azure-location>
74+
az keyvault create --hsm-name <your-managed-hsm-name> --resource-group <your-resource-group-name> --administrators <your-service-principal-object-id> --location <your-azure-location>
7575
```
7676
This service principal is automatically added to the "Managed HSM Administrators" [built-in role][built_in_roles].
7777
7878
* Use the above mentioned Azure Key Vault name to retrieve details of your Vault which also contains your Azure Key Vault URL:
7979
```PowerShell
80-
az keyvault show --hsm-name <your-key-vault-name>
80+
az keyvault show --hsm-name <your-managed-hsm-name> --query properties.hsmUri --output tsv
8181
```
8282
8383
#### Activate your managed HSM
@@ -104,7 +104,7 @@ Use the `az keyvault security-domain download` command to download the security
104104
The example below, uses 3 RSA key pairs (only public keys are needed for this command) and sets the quorum to 2.
105105

106106
```PowerShell
107-
az keyvault security-domain download --hsm-name <your-key-vault-name> --sd-wrapping-keys ./certs/cert_0.cer ./certs/cert_1.cer ./certs/cert_2.cer --sd-quorum 2 --security-domain-file ContosoMHSM-SD.json
107+
az keyvault security-domain download --hsm-name <your-managed-hsm-name> --sd-wrapping-keys ./certs/cert_0.cer ./certs/cert_1.cer ./certs/cert_2.cer --sd-quorum 2 --security-domain-file ContosoMHSM-SD.json
108108
```
109109

110110
#### Controlling access to your managed HSM
@@ -114,25 +114,24 @@ who are able to download a security domain and [manage roles for data plane acce
114114
To perform other actions on keys, you need to assign principals to other roles such as "Managed HSM Crypto User", which can perform non-destructive key operations:
115115

116116
```PowerShell
117-
az keyvault role assignment create --hsm-name <your-key-vault-name> --role "Managed HSM Crypto User" --scope / --assignee-object-id <principal-or-user-object-ID> --assignee-principal-type <principal-type>
117+
az keyvault role assignment create --hsm-name <your-managed-hsm-name> --role "Managed HSM Crypto User" --scope / --assignee-object-id <principal-or-user-object-ID> --assignee-principal-type <principal-type>
118118
```
119119

120120
Please read [best practices][best_practices] for properly securing your managed HSM.
121121

122122
#### Create KeyVaultAccessControlClient
123-
Once you've populated the **AZURE_CLIENT_ID**, **AZURE_CLIENT_SECRET** and **AZURE_TENANT_ID** environment variables and replaced **your-vault-url**
124-
with the above returned URI, you can create the [KeyVaultAccessControlClient][rbac_client]:
123+
Once you've populated the **AZURE_CLIENT_ID**, **AZURE_CLIENT_SECRET**, and **AZURE_TENANT_ID** environment variables, replace **managedHsmUrl** with the output of `az keyvault show` in the example below to create the [KeyVaultAccessControlClient][rbac_client]
125124

126125
```C# Snippet:HelloCreateKeyVaultAccessControlClient
127-
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
126+
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
128127
```
129128

130129
#### Create KeyVaultBackupClient
131-
Once you've populated the **AZURE_CLIENT_ID**, **AZURE_CLIENT_SECRET** and **AZURE_TENANT_ID** environment variables and replaced **your-vault-url**
130+
Once you've populated the **AZURE_CLIENT_ID**, **AZURE_CLIENT_SECRET** and **AZURE_TENANT_ID** environment variables and replaced **your-hsm-url**
132131
with the above returned URI, you can create the [KeyVaultBackupClient][backup_client]:
133132

134133
```C# Snippet:HelloCreateKeyVaultBackupClient
135-
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
134+
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
136135
```
137136

138137
## Key concepts
@@ -270,7 +269,7 @@ additional questions or comments.
270269
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
271270
[rbac_client]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/src/KeyVaultAccessControlClient.cs
272271
[backup_client]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/src/KeyVaultBackupClient.cs
273-
[keyvault_docs]: https://docs.microsoft.com/azure/key-vault/
272+
[managedhsm_docs]: https://docs.microsoft.com/azure/key-vault/managed-hsm/
274273
[keyvault_rest]: https://docs.microsoft.com/rest/api/keyvault/
275274
[admin_client_nuget_package]: https://www.nuget.org/packages?q=Azure.Security.KeyVault.Administration
276275
[admin_client_samples]: https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/keyvault/Azure.Security.KeyVault.Administration/samples

sdk/keyvault/Azure.Security.KeyVault.Administration/samples/Sample1_BackupHelloWorldAsync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can use the [DefaultAzureCredential][DefaultAzureCredential] to try a number
1111
In the sample below, you can set `keyVaultUrl` based on an environment variable, configuration setting, or any way that works for your application.
1212

1313
```C# Snippet:HelloCreateKeyVaultBackupClient
14-
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
14+
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
1515
```
1616

1717
## Performing a full key backup

sdk/keyvault/Azure.Security.KeyVault.Administration/samples/Sample1_BackupHelloWorldSync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can use the [DefaultAzureCredential][DefaultAzureCredential] to try a number
1111
In the sample below, you can set `keyVaultUrl` based on an environment variable, configuration setting, or any way that works for your application.
1212

1313
```C# Snippet:HelloCreateKeyVaultBackupClient
14-
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
14+
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
1515
```
1616

1717
## Performing a full key backup

sdk/keyvault/Azure.Security.KeyVault.Administration/samples/Sample1_RbacHelloWorldAsync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can use the [DefaultAzureCredential][DefaultAzureCredential] to try a number
1111
In the sample below, you can set `keyVaultUrl` based on an environment variable, configuration setting, or any way that works for your application.
1212

1313
```C# Snippet:HelloCreateKeyVaultAccessControlClient
14-
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
14+
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
1515
```
1616

1717
## Listing All Role Definitions

sdk/keyvault/Azure.Security.KeyVault.Administration/samples/Sample1_RbacHelloWorldSync.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ You can use the [DefaultAzureCredential][DefaultAzureCredential] to try a number
1111
In the sample below, you can set `keyVaultUrl` based on an environment variable, configuration setting, or any way that works for your application.
1212

1313
```C# Snippet:HelloCreateKeyVaultAccessControlClient
14-
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
14+
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
1515
```
1616

1717
## Listing All Role Definitions

sdk/keyvault/Azure.Security.KeyVault.Administration/samples/Sample3_BackRestoreResume.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ and check for status or wait for completion.
1212

1313
```C# Snippet:ResumeBackupAsync
1414
// Construct a new KeyVaultBackupClient or use an existing one.
15-
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
15+
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
1616

1717
// Construct a BackupOperation using a KeyVaultBackupClient and the Id from a previously started operation.
1818
KeyVaultBackupOperation backupOperation = new KeyVaultBackupOperation(client, backupOperationId);
@@ -33,7 +33,7 @@ and check for status or wait for completion.
3333

3434
```C# Snippet:ResumeRestoreAsync
3535
// Construct a new KeyVaultBackupClient or use an existing one.
36-
KeyVaultBackupClient Client = new KeyVaultBackupClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
36+
KeyVaultBackupClient Client = new KeyVaultBackupClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
3737

3838
// Construct a RestoreOperation using a KeyVaultBackupClient and the Id from a previously started operation.
3939
KeyVaultRestoreOperation restoreOperation = new KeyVaultRestoreOperation(client, restoreOperationId);

sdk/keyvault/Azure.Security.KeyVault.Administration/tests/samples/AccessControlSampleSnippets.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public void TestSetup()
3131
public void CreateClient()
3232
{
3333
// Environment variable with the Key Vault endpoint.
34-
string keyVaultUrl = TestEnvironment.ManagedHsmUrl;
34+
string managedHsmUrl = TestEnvironment.ManagedHsmUrl;
3535

3636
// Create a new access control client using the default credential from Azure.Identity using environment variables previously set,
3737
// including AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID.
38-
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(vaultUri: new Uri(keyVaultUrl), credential: new DefaultAzureCredential());
38+
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(vaultUri: new Uri(managedHsmUrl), credential: new DefaultAzureCredential());
3939
#if !SNIPPET
4040
client = Client;
4141
#endif

sdk/keyvault/Azure.Security.KeyVault.Administration/tests/samples/Sample1_BackupHelloWorld.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ public Sample1_BackupHelloWorld(bool isAsync, KeyVaultAdministrationClientOption
1818
[Test]
1919
public void CreateClientSample()
2020
{
21-
var keyVaultUrl = TestEnvironment.ManagedHsmUrl;
21+
var managedHsmUrl = TestEnvironment.ManagedHsmUrl;
2222

2323
#region Snippet:HelloCreateKeyVaultBackupClient
24-
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
24+
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
2525
#endregion
2626
}
2727

sdk/keyvault/Azure.Security.KeyVault.Administration/tests/samples/Sample1_RbacHelloWorld.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ public void TestSetup()
3232
public void CreateClient()
3333
{
3434
// Environment variable with the Key Vault endpoint.
35-
string keyVaultUrl = TestEnvironment.ManagedHsmUrl;
35+
string managedHsmUrl = TestEnvironment.ManagedHsmUrl;
3636

3737
#region Snippet:HelloCreateKeyVaultAccessControlClient
38-
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
38+
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
3939
#endregion
4040
client = Client;
4141
}

sdk/keyvault/Azure.Security.KeyVault.Administration/tests/samples/Sample3_BackRestoreResume.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task ResumeBackupRestore()
3434
#region Snippet:ResumeBackupAsync
3535
#if SNIPPET
3636
// Construct a new KeyVaultBackupClient or use an existing one.
37-
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
37+
KeyVaultBackupClient client = new KeyVaultBackupClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
3838
#endif
3939

4040
// Construct a BackupOperation using a KeyVaultBackupClient and the Id from a previously started operation.
@@ -62,7 +62,7 @@ public async Task ResumeBackupRestore()
6262
#region Snippet:ResumeRestoreAsync
6363
#if SNIPPET
6464
// Construct a new KeyVaultBackupClient or use an existing one.
65-
KeyVaultBackupClient Client = new KeyVaultBackupClient(new Uri(keyVaultUrl), new DefaultAzureCredential());
65+
KeyVaultBackupClient Client = new KeyVaultBackupClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
6666
#endif
6767

6868
// Construct a RestoreOperation using a KeyVaultBackupClient and the Id from a previously started operation.

0 commit comments

Comments
 (0)