/mongodb-csfle-csharp-demo-azure

This sample application shows how to integrate Azure Key Vault with MongoDB's Client Side Field Level Encryption.

Primary LanguageC#

Blog Post

https://www.mongodb.com/developer/languages/csharp/use-azure-key-vault-mongodb-client-side-field-level-encryption/

MongoDB Client-Side Field Level Encryption and Azure Key Vault

This sample application demonstrates how to integrate Azure Key Vault with MongoDB's Client Side Field Level Encryption in a .NET Core application.

Workflow diagram of setting up data encryption keys with a key managment system

Dependencies

MongoDB Dependencies

Azure Dependencies

Running the application

  1. Clone this repository:

      git clone https://github.com/adriennetacke/mongodb-csfle-csharp-demo-azure.git
    

    💡 If you decide to share this repo at all, immediately add the launchSettings.json file to your .gitignore file so that you don't inadvertently expose your variables to the world! Well, why is there a launchSettings.json file in your repo, Adrienne? I've deliberately left this file in to make development/learning a bit easier for you. :)

  2. Navigate to the cloned repo's directory and open the application in Visual Studio:

      cd mongodb-csfle-csharp-demo-azure
      EnvoyMedSys.sln
    
  3. Go to Properties > launchSettings.json and update all of the placeholder variables:

    • MDB_ATLAS_URI: The connection string to your MongoDB Atlas cluster. This enables the storage of our data encryption key, encrypted by Azure Key Vault. Be sure to update the <USERNAME>, <PASSWORD>, and <CLUSTER_NAME> portions of the URI with your own credentials!
    • AZURE_TENANT_ID: Identifies the organization of the Azure account.
    • AZURE_CLIENT_ID: Identifies the clientId to authenticate your registered application.
    • AZURE_CLIENT_SECRET: Used to authenticate your registered application.
    • AZURE_KEY_NAME: Name of the Customer Master Key stored in Azure Key Vault.
    • AZURE_KEYVAULT_ENDPOINT: URL of the Key Vault. e.g. yourVaultName.vault.azure.net

More MongoDB Tutorials

Check out these other tutorials from Adrienne:

Follow Adrienne