File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
docs/azure/sdk/snippets/dependency-injection Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 1616 clientBuilder . AddSecretClient ( new Uri ( "<key_vault_url>" ) ) ;
1717 clientBuilder . AddBlobServiceClient ( new Uri ( "<storage_url>" ) ) ;
1818 clientBuilder . AddServiceBusClientWithNamespace ( "<your_namespace>.servicebus.windows.net" ) ;
19+
20+ // Set a credential for all clients to use by default
21+ DefaultAzureCredential credential = new ( ) ;
1922 clientBuilder . UseCredential ( new DefaultAzureCredential ( ) ) ;
2023
2124 // Register subclients for Service Bus
3235 // Register a custom client factory
3336 clientBuilder . AddClient < AzureOpenAIClient , AzureOpenAIClientOptions > (
3437 ( options , _ , _ ) => new AzureOpenAIClient (
35- new Uri ( "<url_here>" ) , new DefaultAzureCredential ( ) , options ) ) ;
38+ new Uri ( "<url_here>" ) , credential , options ) ) ;
3639 } ) ;
3740 } ) . Build ( ) ;
3841
Original file line number Diff line number Diff line change 1616 clientBuilder . AddSecretClient ( new Uri ( "<key_vault_url>" ) ) ;
1717 clientBuilder . AddBlobServiceClient ( new Uri ( "<storage_url>" ) ) ;
1818 clientBuilder . AddServiceBusClientWithNamespace ( "<your_namespace>.servicebus.windows.net" ) ;
19+
20+ // Set a credential for all clients to use by default
21+ DefaultAzureCredential credential = new ( ) ;
1922 clientBuilder . UseCredential ( new DefaultAzureCredential ( ) ) ;
2023
2124 // Register a subclient for each Service Bus Queue
2831
2932 // Register a custom client factory
3033 clientBuilder . AddClient < AzureOpenAIClient , AzureOpenAIClientOptions > (
31- ( options , _ , _ ) => new AzureOpenAIClient (
32- new Uri ( "<url_here>" ) , new DefaultAzureCredential ( ) , options ) ) ;
34+ ( options , _ , _ ) => new AzureOpenAIClient (
35+ new Uri ( "<url_here>" ) , credential , options ) ) ;
3336 } ) ;
3437 } ) . Build ( ) ;
3538
Original file line number Diff line number Diff line change 1616 clientBuilder . AddBlobServiceClient ( new Uri ( "<storage_url>" ) ) ;
1717 clientBuilder . AddServiceBusClientWithNamespace (
1818 "<your_namespace>.servicebus.windows.net" ) ;
19+
20+ // Set a credential for all clients to use by default
21+ DefaultAzureCredential credential = new ( ) ;
1922 clientBuilder . UseCredential ( new DefaultAzureCredential ( ) ) ;
2023
2124 // Register a subclient for each Service Bus Queue
2932 // Register a custom client factory
3033 clientBuilder . AddClient < AzureOpenAIClient , AzureOpenAIClientOptions > (
3134 ( options , _ , _ ) => new AzureOpenAIClient (
32- new Uri ( "<url_here>" ) , new DefaultAzureCredential ( ) , options ) ) ;
35+ new Uri ( "<url_here>" ) , credential , options ) ) ;
3336} ) ;
3437
3538WebApplication app = builder . Build ( ) ;
You can’t perform that action at this time.
0 commit comments