Skip to content

Commit 8e9a77c

Browse files
Improve samples - promote non-credential based authentication (#957)
1 parent 1a71396 commit 8e9a77c

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

doc/samples/AzureKeyVaultProviderExample_2_0.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ public class AzureKeyVaultProviderExample_2_0
1414

1515
// ********* Provide details here ***********
1616
static readonly string s_akvUrl = "https://{KeyVaultName}.vault.azure.net/keys/{Key}/{KeyIdentifier}";
17-
static readonly string s_clientId = "{Application_Client_ID}";
18-
static readonly string s_clientSecret = "{Application_Client_Secret}";
19-
static readonly string s_tenantId = "{Azure_Key_Vault_Active_Directory_Tenant_Id}";
2017
static readonly string s_connectionString = "Server={Server}; Database={database}; Integrated Security=true; Column Encryption Setting=Enabled;";
2118
// ******************************************
2219

2320
public static void Main(string[] args)
2421
{
22+
// Initialize Token Credential instance using InteractiveBrowserCredential. For other authentication options,
23+
// see classes derived from TokenCredential: https://docs.microsoft.com/dotnet/api/azure.core.tokencredential
24+
InteractiveBrowserCredential interactiveBrowserCredential = new InteractiveBrowserCredential();
25+
2526
// Initialize AKV provider
26-
ClientSecretCredential clientSecretCredential = new ClientSecretCredential(s_tenantId, s_clientId, s_clientSecret);
27-
SqlColumnEncryptionAzureKeyVaultProvider akvProvider = new SqlColumnEncryptionAzureKeyVaultProvider(clientSecretCredential);
27+
SqlColumnEncryptionAzureKeyVaultProvider akvProvider = new SqlColumnEncryptionAzureKeyVaultProvider(interactiveBrowserCredential);
2828

2929
// Register AKV provider
3030
SqlConnection.RegisterColumnEncryptionKeyStoreProviders(customProviders: new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>(capacity: 1, comparer: StringComparer.OrdinalIgnoreCase)

doc/samples/AzureKeyVaultProviderWithEnclaveProviderExample_2_0.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@ class Program
1515

1616
// ********* Provide details here ***********
1717
static readonly string s_akvUrl = "https://{KeyVaultName}.vault.azure.net/keys/{Key}/{KeyIdentifier}";
18-
static readonly string s_clientId = "{Application_Client_ID}";
19-
static readonly string s_clientSecret = "{Application_Client_Secret}";
20-
static readonly string s_tenantId = "{Azure_Key_Vault_Active_Directory_Tenant_Id}";
2118
static readonly string s_connectionString = "Server={Server}; Database={database}; Integrated Security=true; Column Encryption Setting=Enabled; Attestation Protocol=HGS; Enclave Attestation Url = {attestation_url_for_HGS};";
2219
// ******************************************
2320

2421
static void Main(string[] args)
2522
{
23+
// Initialize Token Credential instance using InteractiveBrowserCredential. For other authentication options,
24+
// see classes derived from TokenCredential: https://docs.microsoft.com/dotnet/api/azure.core.tokencredential
25+
InteractiveBrowserCredential interactiveBrowserCredential = new InteractiveBrowserCredential();
26+
2627
// Initialize AKV provider
27-
ClientSecretCredential clientSecretCredential = new ClientSecretCredential(s_tenantId, s_clientId, s_clientSecret);
28-
SqlColumnEncryptionAzureKeyVaultProvider akvProvider = new SqlColumnEncryptionAzureKeyVaultProvider(clientSecretCredential);
28+
SqlColumnEncryptionAzureKeyVaultProvider akvProvider = new SqlColumnEncryptionAzureKeyVaultProvider(interactiveBrowserCredential);
2929

3030
// Register AKV provider
3131
SqlConnection.RegisterColumnEncryptionKeyStoreProviders(customProviders: new Dictionary<string, SqlColumnEncryptionKeyStoreProvider>(capacity: 1, comparer: StringComparer.OrdinalIgnoreCase)

0 commit comments

Comments
 (0)