public Secret UpdateSecret(string vaultName, string secretName, string secretVersion, SecretAttributes secretAttributes) { if (string.IsNullOrEmpty(vaultName)) { throw new ArgumentNullException("vaultName"); } if (string.IsNullOrEmpty(secretName)) { throw new ArgumentNullException("secretName"); } if (secretAttributes == null) { throw new ArgumentNullException("secretAttributes"); } var secretIdentifier = new Microsoft.Azure.KeyVault.SecretIdentifier(this.vaultUriHelper.CreateVaultAddress(vaultName), secretName, secretVersion); Microsoft.Azure.KeyVault.SecretAttributes attributes = (Microsoft.Azure.KeyVault.SecretAttributes)secretAttributes; Microsoft.Azure.KeyVault.Secret secret; try { secret = this.keyVaultClient.UpdateSecretAsync(secretIdentifier.Identifier, secretAttributes.ContentType, attributes, secretAttributes.TagsDirectionary).GetAwaiter().GetResult(); } catch (Exception ex) { throw GetInnerException(ex); } return(new Secret(secret, this.vaultUriHelper)); }
/// <summary> /// Updates the attributes associated with the specified secret /// </summary> /// <param name="secretIdentifier">The URL of the secret</param> /// <param name="contentType">Type of the secret value such as password.</param> /// <param name="tags">Application-specific metadata in the form of key-value pairs</param> /// <param name="secretAttributes">Attributes for the secret. For more information on possible attributes, see SecretAttributes.</param> /// <param name="cancellationToken">Optional cancellation token</param> /// <returns>A response message containing the updated secret</returns> public static async Task <SecretBundle> UpdateSecretAsync(this IKeyVaultClient operations, string secretIdentifier, string contentType = null, SecretAttributes secretAttributes = null, Dictionary <string, string> tags = null, CancellationToken cancellationToken = default(CancellationToken)) { if (string.IsNullOrEmpty(secretIdentifier)) { throw new ArgumentNullException(nameof(secretIdentifier)); } var secretId = new SecretIdentifier(secretIdentifier); using (var _result = await operations.UpdateSecretWithHttpMessagesAsync(secretId.Vault, secretId.Name, secretId.Version, contentType, secretAttributes, tags, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Default constructor /// </summary> public Secret() { Attributes = new SecretAttributes(); }