Invalid key store provider name: 'AZURE_KEY_VAULT' - Asp.net core 6

Cristopher Aguilera 51 Reputation points
2022-01-10T23:22:27.797+00:00

Good afternoon,

I have an asp.NET core 6 application connected to a Azure SQL Database, one of the pages queries does a select to an always encrypted column, the encryption key is stored using Azure key vault. When I compile the app, I get the following error:

Failed to decrypt a column encryption key. Invalid key store provider name: 'AZURE_KEY_VAULT'. A key store provider name must denote either a system key store provider or a registered custom key store provider. Valid system key store provider names are: 'MSSQL_CERTIFICATE_STORE', 'MSSQL_CNG_STORE', 'MSSQL_CSP_PROVIDER'. Valid (currently registered) custom key store provider names are: . Please verify key store provider information in column master key definitions in the database, and verify all custom key store providers used in your application are registered properly.

I tried to follow the steps on https://learn.microsoft.com/en-us/sql/connect/ado-net/sql/sqlclient-support-always-encrypted?view=sql-server-ver15, however the examples are not for .NET core 6 and therefore I can't really follow the steps in the documentation.

Does anyone have a working example of a .NET core 6 app with always encrypted? Or know how to register the azure_key_vault provider to the application?

All the documentation I have found online is very convoluted and almost impossible to follow...

Thanks in advance,
Cris

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,135 questions
Azure SQL Database
{count} votes

2 answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 56,926 Reputation points
    2022-02-01T02:15:31.437+00:00

    Azure key vault is not a builtin provider, thus the error message. You probable want to use the nuget package

    https://www.nuget.org/packages/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider

    The with the sql connection you register the provider. See this example

    https://learn.microsoft.com/en-us/azure/azure-sql/database/always-encrypted-azure-key-vault-configure?tabs=azure-powershell

    Note: if you are using DI, you could create the provider and register with the builder.

    1 person found this answer helpful.

  2. Bruce (SqlWork.com) 56,926 Reputation points
    2022-01-11T16:37:08.777+00:00

    as its all supported by the SQLClient library there are no changes for .net 6. show your code so we can see the coding error.