コード例 #1
0
        // </Main>

        private static CosmosClient CreateClientInstance(
            IConfigurationRoot configuration,
            IKeyEncryptionKeyResolver keyResolver)
        {
            string endpoint = configuration["EndPointUrl"];

            if (string.IsNullOrEmpty(endpoint))
            {
                throw new ArgumentNullException("Please specify a valid endpoint in the appSettings.json");
            }

            string authKey = configuration["AuthorizationKey"];

            if (string.IsNullOrEmpty(authKey) || string.Equals(authKey, "Super secret key"))
            {
                throw new ArgumentException("Please specify a valid AuthorizationKey in the appSettings.json");
            }

            CosmosClientOptions options = new CosmosClientOptions
            {
                AllowBulkExecution = true,
            };
            CosmosClient encryptionCosmosClient = new CosmosClient(endpoint, authKey, options);

            // enable encryption support on the cosmos client.
            return(encryptionCosmosClient.WithEncryption(keyResolver, KeyEncryptionKeyResolverName.AzureKeyVault));
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: n1l/azure-cosmos-dotnet-v3
        // </Main>

        private static CosmosClient CreateClientInstance(IConfigurationRoot configuration, AzureKeyVaultKeyWrapProvider azureKeyVaultKeyWrapProvider)
        {
            string endpoint = configuration["EndPointUrl"];

            if (string.IsNullOrEmpty(endpoint))
            {
                throw new ArgumentNullException("Please specify a valid endpoint in the appSettings.json");
            }

            string authKey = configuration["AuthorizationKey"];

            if (string.IsNullOrEmpty(authKey) || string.Equals(authKey, "Super secret key"))
            {
                throw new ArgumentException("Please specify a valid AuthorizationKey in the appSettings.json");
            }

            CosmosClient encryptionCosmosClient = new CosmosClient(endpoint, authKey);

            // enable encryption support on the cosmos client.
            return(encryptionCosmosClient.WithEncryption(azureKeyVaultKeyWrapProvider));
        }