I'm having a problem while making a powershell script for creation of Always Encrypted column encryption keys
When I run these functions from the SqlServer powershell module, I get the following error.
# $cngProviderName "Microsoft Software Key Storage Provider"; # $cngKeyName = name of the CngKeyIdentifier $cmkSettings = New-SqlCngColumnMasterKeySettings -CngProviderName $cngProviderName -KeyName $cngKeyName; # This command is throwing the exception $encryptedValue = New-SqlColumnEncryptionKeyEncryptedValue -TargetColumnMasterKeySettings $cmkSettings
S System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Management.AlwaysEncrypted.Types.AlwaysEncryptedManager' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeInitializationException: The type initializer for 'Microsoft.SqlServer.Management.AlwaysEncrypted.Management.AlwaysEncryptedManagement' threw an exception. ---> System.TypeLoadException: Method 'get_SerializationSettings' in type 'Microsoft.Azure.KeyVault.KeyVaultClient' from assembly 'Microsoft.Azure.KeyVault, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' does not have an implementation.
I'm really puzzled as to why I'm getting the error, I'm not using the Azure KeyVault based functionality, and I'm not sure why I get this reflection error.
I've tried extensively looking for this error, but I couldn't find the problem. When using the certificate based approach I get the same problem.
Is there any one who can tell me how to resolve this issue?