Skip to content

Commit 9f6a490

Browse files
authored
Add KeyVaultSettingsClient (Azure#31984)
* Add KeyVaultSettingsClient * Prototype type-specific getters Similar to JsonElement's methods. * Resolve some architect feedback * Change KeyVaultSetting design to mimic Form Recognizer * --amend * More changes to KeyVaultSetting from architects Also re-recorded all the tests with 7.4-preview.1 and added more tests, completing Azure#31847. * Update public API and samples * Use absolute URLs for links * Regenerate after rebase on main * Resolve PR feedback
1 parent 646af7d commit 9f6a490

File tree

81 files changed

+4230
-3877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+4230
-3877
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
### Features Added
66

7+
- Added `KeyVaultSettingsClient` to get and update Managed HSM settings.
8+
79
### Breaking Changes
810

911
### Bugs Fixed

sdk/keyvault/Azure.Security.KeyVault.Administration/api/Azure.Security.KeyVault.Administration.netstandard2.0.cs

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ public CreateOrUpdateRoleDefinitionOptions(Azure.Security.KeyVault.Administratio
1111
public string RoleName { get { throw null; } set { } }
1212
public Azure.Security.KeyVault.Administration.KeyVaultRoleScope RoleScope { get { throw null; } }
1313
}
14+
public partial class GetSettingsResult
15+
{
16+
internal GetSettingsResult() { }
17+
public System.Collections.Generic.IReadOnlyList<Azure.Security.KeyVault.Administration.KeyVaultSetting> Settings { get { throw null; } }
18+
}
1419
public partial class KeyVaultAccessControlClient
1520
{
1621
protected KeyVaultAccessControlClient() { }
@@ -38,19 +43,21 @@ public KeyVaultAccessControlClient(System.Uri vaultUri, Azure.Core.TokenCredenti
3843
}
3944
public partial class KeyVaultAdministrationClientOptions : Azure.Core.ClientOptions
4045
{
41-
public KeyVaultAdministrationClientOptions(Azure.Security.KeyVault.Administration.KeyVaultAdministrationClientOptions.ServiceVersion version = Azure.Security.KeyVault.Administration.KeyVaultAdministrationClientOptions.ServiceVersion.V7_3) { }
46+
public KeyVaultAdministrationClientOptions(Azure.Security.KeyVault.Administration.KeyVaultAdministrationClientOptions.ServiceVersion version = Azure.Security.KeyVault.Administration.KeyVaultAdministrationClientOptions.ServiceVersion.V7_4_Preview_1) { }
4247
public bool DisableChallengeResourceVerification { get { throw null; } set { } }
4348
public Azure.Security.KeyVault.Administration.KeyVaultAdministrationClientOptions.ServiceVersion Version { get { throw null; } }
4449
public enum ServiceVersion
4550
{
4651
V7_2 = 1,
4752
V7_3 = 2,
53+
V7_4_Preview_1 = 3,
4854
}
4955
}
5056
public static partial class KeyVaultAdministrationModelFactory
5157
{
5258
public static Azure.Security.KeyVault.Administration.KeyVaultBackupOperation BackupOperation(Azure.Response response, Azure.Security.KeyVault.Administration.KeyVaultBackupClient client, string id, System.Uri blobContainerUri, System.DateTimeOffset? startTime = default(System.DateTimeOffset?), System.DateTimeOffset? endTime = default(System.DateTimeOffset?), string errorMessage = null) { throw null; }
5359
public static Azure.Security.KeyVault.Administration.KeyVaultBackupResult BackupResult(System.Uri folderUri, System.DateTimeOffset startTime, System.DateTimeOffset endTime) { throw null; }
60+
public static Azure.Security.KeyVault.Administration.GetSettingsResult GetSettingsResult(System.Collections.Generic.IEnumerable<Azure.Security.KeyVault.Administration.KeyVaultSetting> settings = null) { throw null; }
5461
public static Azure.Security.KeyVault.Administration.KeyVaultRoleAssignment KeyVaultRoleAssignment(string id = null, string name = null, string type = null, Azure.Security.KeyVault.Administration.KeyVaultRoleAssignmentProperties properties = null) { throw null; }
5562
public static Azure.Security.KeyVault.Administration.KeyVaultRoleAssignmentProperties KeyVaultRoleAssignmentProperties(Azure.Security.KeyVault.Administration.KeyVaultRoleScope? scope = default(Azure.Security.KeyVault.Administration.KeyVaultRoleScope?), string roleDefinitionId = null, string principalId = null) { throw null; }
5663
public static Azure.Security.KeyVault.Administration.KeyVaultRoleDefinition KeyVaultRoleDefinition(string id = null, string name = null, Azure.Security.KeyVault.Administration.KeyVaultRoleDefinitionType? type = default(Azure.Security.KeyVault.Administration.KeyVaultRoleDefinitionType?), string roleName = null, string description = null, Azure.Security.KeyVault.Administration.KeyVaultRoleType? roleType = default(Azure.Security.KeyVault.Administration.KeyVaultRoleType?), System.Collections.Generic.IEnumerable<Azure.Security.KeyVault.Administration.KeyVaultPermission> permissions = null, System.Collections.Generic.IEnumerable<Azure.Security.KeyVault.Administration.KeyVaultRoleScope> assignableScopes = null) { throw null; }
@@ -281,4 +288,43 @@ internal KeyVaultSelectiveKeyRestoreResult() { }
281288
public System.DateTimeOffset EndTime { get { throw null; } }
282289
public System.DateTimeOffset StartTime { get { throw null; } }
283290
}
291+
public partial class KeyVaultSetting
292+
{
293+
public KeyVaultSetting(string name, bool value) { }
294+
public string Name { get { throw null; } }
295+
public Azure.Security.KeyVault.Administration.SettingType? Type { get { throw null; } }
296+
public bool AsBoolean() { throw null; }
297+
public string AsString() { throw null; }
298+
public override string ToString() { throw null; }
299+
}
300+
public partial class KeyVaultSettingsClient
301+
{
302+
protected KeyVaultSettingsClient() { }
303+
public KeyVaultSettingsClient(System.Uri vaultUri, Azure.Core.TokenCredential credential) { }
304+
public KeyVaultSettingsClient(System.Uri vaultUri, Azure.Core.TokenCredential credential, Azure.Security.KeyVault.Administration.KeyVaultAdministrationClientOptions options) { }
305+
public virtual System.Uri VaultUri { get { throw null; } }
306+
public virtual Azure.Response<Azure.Security.KeyVault.Administration.KeyVaultSetting> GetSetting(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
307+
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Administration.KeyVaultSetting>> GetSettingAsync(string name, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
308+
public virtual Azure.Response<Azure.Security.KeyVault.Administration.GetSettingsResult> GetSettings(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
309+
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Administration.GetSettingsResult>> GetSettingsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
310+
public virtual Azure.Response<Azure.Security.KeyVault.Administration.KeyVaultSetting> UpdateSetting(Azure.Security.KeyVault.Administration.KeyVaultSetting setting, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
311+
public virtual System.Threading.Tasks.Task<Azure.Response<Azure.Security.KeyVault.Administration.KeyVaultSetting>> UpdateSettingAsync(Azure.Security.KeyVault.Administration.KeyVaultSetting setting, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
312+
}
313+
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
314+
public readonly partial struct SettingType : System.IEquatable<Azure.Security.KeyVault.Administration.SettingType>
315+
{
316+
private readonly object _dummy;
317+
private readonly int _dummyPrimitive;
318+
public SettingType(string value) { throw null; }
319+
public static Azure.Security.KeyVault.Administration.SettingType Boolean { get { throw null; } }
320+
public bool Equals(Azure.Security.KeyVault.Administration.SettingType other) { throw null; }
321+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
322+
public override bool Equals(object obj) { throw null; }
323+
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
324+
public override int GetHashCode() { throw null; }
325+
public static bool operator ==(Azure.Security.KeyVault.Administration.SettingType left, Azure.Security.KeyVault.Administration.SettingType right) { throw null; }
326+
public static implicit operator Azure.Security.KeyVault.Administration.SettingType (string value) { throw null; }
327+
public static bool operator !=(Azure.Security.KeyVault.Administration.SettingType left, Azure.Security.KeyVault.Administration.SettingType right) { throw null; }
328+
public override string ToString() { throw null; }
329+
}
284330
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Performing a full key backup and restore (Async)
22

3-
This sample demonstrates how to a perform full key backup and restore in Azure Key Vault.
4-
To get started, you'll need a URI to an Azure Key Vault. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/README.md) for links and instructions.
3+
This sample demonstrates how to a perform full key backup and restore in Azure Managed HSM.
4+
To get started, you'll need a URI to an Azure Managed HSM. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/README.md) for links and instructions.
55

66
## Creating a KeyVaultBackupClient
77

8-
To create a new `KeyVaultBackupClient`, you'll need the endpoint to an Azure Key Vault and credentials.
8+
To create a new `KeyVaultBackupClient`, you'll need the endpoint to an Azure Managed HSM and credentials.
99
You can use the [DefaultAzureCredential][DefaultAzureCredential] to try a number of common authentication methods optimized for both running as a service and development.
1010

11-
In the sample below, you can set `keyVaultUrl` based on an environment variable, configuration setting, or any way that works for your application.
11+
In the sample below, you can set `managedHsmUrl` based on an environment variable, configuration setting, or any way that works for your application.
1212

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

1717
## Performing a full key backup
1818

19-
Using the `KeyVaultBackupClient`, you can back up your entire collection of keys. The backing store for full key backups is a blob storage container using Shared Access Signature authentication.
19+
Using the `KeyVaultBackupClient`, you can back up your entire collection of keys. The backing store for full key backups is a blob storage container using Shared Access Signature authentication.
2020
For more details on creating a SAS token using the `BlobServiceClient`, see the [Azure Storage Blobs client README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/README.md) and the [authentication samples](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/samples/Sample02_Auth.cs).
2121
Alternatively, it is possible to [generate a SAS token in Storage Explorer](https://docs.microsoft.com/azure/vs-azure-tools-storage-manage-with-storage-explorer?tabs=windows#generate-a-shared-access-signature-in-storage-explorer)
2222

@@ -44,7 +44,7 @@ Uri folderUri = backupResult.Value.FolderUri;
4444

4545
## Performing a full key restore
4646

47-
Using the `KeyVaultBackupClient`, you can restore your entire collection of keys from backup. The data source for full key restore is a storage blob accessed using Shared Access Signature authentication.
47+
Using the `KeyVaultBackupClient`, you can restore your entire collection of keys from backup. The data source for full key restore is a storage blob accessed using Shared Access Signature authentication.
4848
For more details on creating a SAS token using the `BlobServiceClient`, see the [Azure Storage Blobs client README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/README.md) and the [authentication samples](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/samples/Sample02_Auth.cs).
4949
Alternatively, it is possible to [generate a SAS token in Storage Explorer](https://docs.microsoft.com/azure/vs-azure-tools-storage-manage-with-storage-explorer?tabs=windows#generate-a-shared-access-signature-in-storage-explorer)
5050

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
# Performing a full key backup and restore (Sync)
22

3-
This sample demonstrates how to perform a full key backup and restore in Azure Key Vault.
4-
To get started, you'll need a URI to an Azure Key Vault. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/README.md) for links and instructions.
3+
This sample demonstrates how to perform a full key backup and restore in Azure Managed HSM.
4+
To get started, you'll need a URI to an Azure Managed HSM. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/README.md) for links and instructions.
55

66
## Creating a KeyVaultBackupClient
77

8-
To create a new `KeyVaultBackupClient`, you'll need the endpoint to an Azure Key Vault and credentials.
8+
To create a new `KeyVaultBackupClient`, you'll need the endpoint to an Azure Managed HSM and credentials.
99
You can use the [DefaultAzureCredential][DefaultAzureCredential] to try a number of common authentication methods optimized for both running as a service and development.
1010

11-
In the sample below, you can set `keyVaultUrl` based on an environment variable, configuration setting, or any way that works for your application.
11+
In the sample below, you can set `managedHsmUrl` based on an environment variable, configuration setting, or any way that works for your application.
1212

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

1717
## Performing a full key backup
1818

19-
Using the `KeyVaultBackupClient`, you can back up your entire collection of keys. The backing store for full key backups is a blob storage container using Shared Access Signature authentication.
19+
Using the `KeyVaultBackupClient`, you can back up your entire collection of keys. The backing store for full key backups is a blob storage container using Shared Access Signature authentication.
2020
For more details on creating a SAS token using the `BlobServiceClient`, see the [Azure Storage Blobs client README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/README.md) and the [authentication samples](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/samples/Sample02_Auth.cs).
2121
Alternatively, it is possible to [generate a SAS token in Storage Explorer](https://docs.microsoft.com/azure/vs-azure-tools-storage-manage-with-storage-explorer?tabs=windows#generate-a-shared-access-signature-in-storage-explorer)
2222

@@ -48,7 +48,7 @@ Uri folderUri = backupOperation.Value.FolderUri;
4848

4949
## Performing a full key restore
5050

51-
Using the `KeyVaultBackupClient`, you can restore your entire collection of keys from backup. The data source for full key restore is a storage blob accessed using Shared Access Signature authentication.
51+
Using the `KeyVaultBackupClient`, you can restore your entire collection of keys from backup. The data source for full key restore is a storage blob accessed using Shared Access Signature authentication.
5252
For more details on creating a SAS token using the `BlobServiceClient`, see the [Azure Storage Blobs client README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/README.md) and the [authentication samples](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/storage/Azure.Storage.Blobs/samples/Sample02_Auth.cs).
5353
Alternatively, it is possible to [generate a SAS token in Storage Explorer](https://docs.microsoft.com/azure/vs-azure-tools-storage-manage-with-storage-explorer?tabs=windows#generate-a-shared-access-signature-in-storage-explorer)
5454

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Creating, getting, and deleting role assignments (Async)
22

3-
This sample demonstrates how to create, get, and delete role assignments in Azure Key Vault.
4-
To get started, you'll need a URI to an Azure Key Vault. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/README.md) for links and instructions.
3+
This sample demonstrates how to create, get, and delete role assignments in Azure Managed HSM.
4+
To get started, you'll need a URI to an Azure Managed HSM. See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/README.md) for links and instructions.
55

66
## Creating a KeyVaultAccessControlClient
77

8-
To create a new `KeyVaultAccessControlClient` to create, get, or delete role assignments, you need the endpoint to an Azure Key Vault and credentials.
8+
To create a new `KeyVaultAccessControlClient` to create, get, or delete role assignments, you need the endpoint to an Azure Managed HSM and credentials.
99
You can use the [DefaultAzureCredential][DefaultAzureCredential] to try a number of common authentication methods optimized for both running as a service and development.
1010

11-
In the sample below, you can set `keyVaultUrl` based on an environment variable, configuration setting, or any way that works for your application.
11+
In the sample below, you can set `managedHsmUrl` based on an environment variable, configuration setting, or any way that works for your application.
1212

1313
```C# Snippet:HelloCreateKeyVaultAccessControlClient
1414
KeyVaultAccessControlClient client = new KeyVaultAccessControlClient(new Uri(managedHsmUrl), new DefaultAzureCredential());
@@ -46,7 +46,8 @@ A role definition Id can be obtained from the `Id` property of one of the role d
4646

4747
See the [README](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/keyvault/Azure.Security.KeyVault.Administration/README.md) for links and instructions on how to generate a new service principal and obtain it's object Id.
4848
You can also get the object Id for your currently signed in account by running the following [Azure CLI][azure_cli] command.
49-
```
49+
50+
```PowerShell
5051
az ad signed-in-user show --query objectId
5152
```
5253

@@ -66,6 +67,7 @@ KeyVaultRoleAssignment fetchedAssignment = await client.GetRoleAssignmentAsync(K
6667
```
6768

6869
## Deleting a Role Assignment
70+
6971
To remove a role assignment from a service principal, the role assignment must be deleted. Let's delete the `createdAssignment` from the previous example.
7072

7173
```C# Snippet:DeleteRoleAssignmentAsync

0 commit comments

Comments
 (0)