use DefaultAzureCredential instead of AzureCliCredential (#3860)

This commit is contained in:
SergeyMenshykh
2026-02-12 12:27:54 +00:00
committed by GitHub
Unverified
parent 6a88c7b1a1
commit 6000b737e9
113 changed files with 435 additions and 105 deletions
@@ -110,7 +110,10 @@ static async Task<string> GetWeatherAsync([Description("The location to get the
return $"The weather in {location} is cloudy with a high of 15°C.";
}
using var instrumentedChatClient = new AzureOpenAIClient(new Uri(endpoint), new AzureCliCredential())
// WARNING: DefaultAzureCredential is convenient for development but requires careful consideration in production.
// In production, consider using a specific credential (e.g., ManagedIdentityCredential) to avoid
// latency issues, unintended credential probing, and potential security risks from fallback mechanisms.
using var instrumentedChatClient = new AzureOpenAIClient(new Uri(endpoint), new DefaultAzureCredential())
.GetChatClient(deploymentName)
.AsIChatClient() // Converts a native OpenAI SDK ChatClient into a Microsoft.Extensions.AI.IChatClient
.AsBuilder()