public KeyBundle UpdateKey(string vaultName, string keyName, string keyVersion, KeyAttributes keyAttributes)
        {
            if (string.IsNullOrEmpty(vaultName))
            {
                throw new ArgumentNullException("vaultName");
            }
            if (string.IsNullOrEmpty(keyName))
            {
                throw new ArgumentNullException("keyName");
            }
            if (keyAttributes == null)
            {
                throw new ArgumentNullException("keyAttributes");
            }

            Microsoft.Azure.KeyVault.KeyAttributes attributes = (Microsoft.Azure.KeyVault.KeyAttributes)keyAttributes;
            var keyIdentifier = new KeyIdentifier(this.vaultUriHelper.CreateVaultAddress(vaultName), keyName, keyVersion);

            Microsoft.Azure.KeyVault.KeyBundle keyBundle;
            try
            {
                keyBundle = this.keyVaultClient.UpdateKeyAsync(
                    keyIdentifier.Identifier, keyAttributes.KeyOps, attributes: attributes, tags: keyAttributes.TagsDirectionary).GetAwaiter().GetResult();
            }
            catch (Exception ex)
            {
                throw GetInnerException(ex);
            }

            return(new KeyBundle(keyBundle, this.vaultUriHelper));
        }
Exemple #2
0
        /// <summary>
        /// Updates the Key Attributes associated with the specified key
        /// </summary>
        /// <param name="keyIdentifier">The key identifier</param>
        /// <param name="keyOps">Json web key operations. For more information, see JsonWebKeyOperation.</param>
        /// <param name="attributes">The new attributes for the key. For more information on key attributes, see KeyAttributes.</param>
        /// <param name="tags">Application-specific metadata in the form of key-value pairs</param>
        /// <param name="cancellationToken">Optional cancellation token</param>
        /// <returns> The updated key </returns>
        public static async Task <KeyBundle> UpdateKeyAsync(this IKeyVaultClient operations, string keyIdentifier, string[] keyOps = null, KeyAttributes attributes = null, Dictionary <string, string> tags = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(keyIdentifier))
            {
                throw new ArgumentNullException(nameof(keyIdentifier));
            }

            var keyId = new KeyIdentifier(keyIdentifier);

            using (var _result = await operations.UpdateKeyWithHttpMessagesAsync(keyId.Vault, keyId.Name, keyId.Version ?? string.Empty, keyOps, attributes, tags, null, cancellationToken).ConfigureAwait(false))
            {
                return(_result.Body);
            }
        }
 public async Task<KeyBundle> UpdateKey(string keyName, KeyAttributes keyAttributes)
 {
     return await keyVaultClient.UpdateKeyAsync(keyVaultUri, keyName, attributes: keyAttributes);
 }
Exemple #4
0
 /// <summary>
 /// Default constructor
 /// </summary>
 public KeyBundle()
 {
     Key        = new JsonWebKey();
     Attributes = new KeyAttributes();
 }
Exemple #5
0
        /// <summary>
        /// Updates the Key Attributes associated with the specified key
        /// </summary>
        /// <param name="vaultBaseUrl">The vault name, e.g. https://myvault.vault.azure.net</param>
        /// <param name="keyName">The key name</param>
        /// <param name="keyOps">Json web key operations. For more information on possible key operations, see JsonWebKeyOperation.</param>
        /// <param name="attributes">The new attributes for the key. For more information on key attributes, see KeyAttributes.</param>
        /// <param name="tags">Application-specific metadata in the form of key-value pairs</param>
        /// <returns> The updated key </returns>
        public static async Task <KeyBundle> UpdateKeyAsync(this IKeyVaultClient operations, string vaultBaseUrl, string keyName, string[] keyOps = null, KeyAttributes attributes = null, Dictionary <string, string> tags = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (string.IsNullOrEmpty(vaultBaseUrl))
            {
                throw new ArgumentNullException("vaultBaseUrl");
            }

            if (string.IsNullOrEmpty(keyName))
            {
                throw new ArgumentNullException("keyName");
            }

            using (var _result = await operations.UpdateKeyWithHttpMessagesAsync(vaultBaseUrl, keyName, string.Empty, keyOps, attributes, tags, null, cancellationToken).ConfigureAwait(false))
            {
                return(_result.Body);
            }
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 public KeyBundle()
 {
     Key        = new JsonWebKey();
     Attributes = new KeyAttributes();
 }