diff --git a/.github/workflows/dotnet-build-and-test.yml b/.github/workflows/dotnet-build-and-test.yml
index f46adb441a41..034c959e6dde 100644
--- a/.github/workflows/dotnet-build-and-test.yml
+++ b/.github/workflows/dotnet-build-and-test.yml
@@ -21,6 +21,7 @@ concurrency:
permissions:
contents: read
+ id-token: "write"
jobs:
paths-filter:
@@ -57,11 +58,13 @@ jobs:
os: "ubuntu-latest",
configuration: Release,
integration-tests: true,
+ environment: "integration",
}
- { dotnet: "8.0", os: "windows-latest", configuration: Debug }
- { dotnet: "8.0", os: "windows-latest", configuration: Release }
runs-on: ${{ matrix.os }}
+ environment: ${{ matrix.environment }}
steps:
- uses: actions/checkout@v4
- name: Setup dotnet ${{ matrix.dotnet }}
@@ -84,6 +87,14 @@ jobs:
dotnet test -c ${{ matrix.configuration }} $project --no-build -v Normal --logger trx --collect:"XPlat Code Coverage" --results-directory:"TestResults/Coverage/" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByAttribute=GeneratedCodeAttribute,CompilerGeneratedAttribute,ExcludeFromCodeCoverageAttribute
done
+ - name: Azure CLI Login
+ if: github.event_name != 'pull_request' && matrix.integration-tests
+ uses: azure/login@v2
+ with:
+ client-id: ${{ secrets.AZURE_CLIENT_ID }}
+ tenant-id: ${{ secrets.AZURE_TENANT_ID }}
+ subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
+
- name: Run Integration Tests
shell: bash
if: github.event_name != 'pull_request' && matrix.integration-tests
diff --git a/dotnet/src/Connectors/Connectors.AzureOpenAI/Extensions/AzureOpenAIKernelBuilderExtensions.cs b/dotnet/src/Connectors/Connectors.AzureOpenAI/Extensions/AzureOpenAIKernelBuilderExtensions.cs
index 86fbc7ac59df..5b42c6104373 100644
--- a/dotnet/src/Connectors/Connectors.AzureOpenAI/Extensions/AzureOpenAIKernelBuilderExtensions.cs
+++ b/dotnet/src/Connectors/Connectors.AzureOpenAI/Extensions/AzureOpenAIKernelBuilderExtensions.cs
@@ -249,6 +249,43 @@ public static IKernelBuilder AddAzureOpenAITextEmbeddingGeneration(
return builder;
}
+ ///
+ /// Adds the to the .
+ ///
+ /// The instance to augment.
+ /// Azure OpenAI deployment name, see https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource
+ /// Azure OpenAI deployment URL, see https://learn.microsoft.com/azure/cognitive-services/openai/quickstart
+ /// Token credentials, e.g. DefaultAzureCredential, ManagedIdentityCredential, EnvironmentCredential, etc.
+ /// A local identifier for the given AI service
+ /// Model identifier, see https://learn.microsoft.com/azure/cognitive-services/openai/quickstart
+ /// The HttpClient to use with this service.
+ /// The same instance as .
+ [Experimental("SKEXP0010")]
+ public static IKernelBuilder AddAzureOpenAITextToAudio(
+ this IKernelBuilder builder,
+ string deploymentName,
+ string endpoint,
+ TokenCredential credential,
+ string? serviceId = null,
+ string? modelId = null,
+ HttpClient? httpClient = null)
+ {
+ Verify.NotNull(builder);
+ Verify.NotNullOrWhiteSpace(endpoint);
+ Verify.NotNull(credential);
+
+ builder.Services.AddKeyedSingleton(serviceId, (serviceProvider, _) =>
+ new AzureOpenAITextToAudioService(
+ deploymentName,
+ endpoint,
+ credential,
+ modelId,
+ HttpClientProvider.GetHttpClient(httpClient, serviceProvider),
+ serviceProvider.GetService()));
+
+ return builder;
+ }
+
#endregion
#region Text-to-Audio
diff --git a/dotnet/src/Connectors/Connectors.AzureOpenAI/Services/AzureOpenAITextToAudioService.cs b/dotnet/src/Connectors/Connectors.AzureOpenAI/Services/AzureOpenAITextToAudioService.cs
index 0b9f98302a0b..0863d156a5b4 100644
--- a/dotnet/src/Connectors/Connectors.AzureOpenAI/Services/AzureOpenAITextToAudioService.cs
+++ b/dotnet/src/Connectors/Connectors.AzureOpenAI/Services/AzureOpenAITextToAudioService.cs
@@ -7,6 +7,7 @@
using System.Threading;
using System.Threading.Tasks;
using Azure.AI.OpenAI;
+using Azure.Core;
using Microsoft.Extensions.Logging;
using Microsoft.SemanticKernel.Services;
using Microsoft.SemanticKernel.TextToAudio;
@@ -69,6 +70,38 @@ public AzureOpenAITextToAudioService(
this._modelId = modelId;
}
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// Azure OpenAI deployment name, see https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource
+ /// Azure OpenAI deployment URL, see https://learn.microsoft.com/azure/cognitive-services/openai/quickstart
+ /// Token credentials, e.g. DefaultAzureCredential, ManagedIdentityCredential, EnvironmentCredential, etc.
+ /// Azure OpenAI model id, see https://learn.microsoft.com/azure/cognitive-services/openai/how-to/create-resource
+ /// Custom for HTTP requests.
+ /// The to use for logging. If null, no logging will be performed.
+ public AzureOpenAITextToAudioService(
+ string deploymentName,
+ string endpoint,
+ TokenCredential credential,
+ string? modelId = null,
+ HttpClient? httpClient = null,
+ ILoggerFactory? loggerFactory = null)
+ {
+ var url = !string.IsNullOrWhiteSpace(httpClient?.BaseAddress?.AbsoluteUri) ? httpClient!.BaseAddress!.AbsoluteUri : endpoint;
+
+ var options = AzureClientCore.GetAzureOpenAIClientOptions(
+ httpClient,
+ AzureOpenAIClientOptions.ServiceVersion.V2024_05_01_Preview); // https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#text-to-speech
+
+ var azureOpenAIClient = new AzureOpenAIClient(new Uri(url), credential, options);
+
+ this._client = new(deploymentName, azureOpenAIClient, loggerFactory?.CreateLogger(typeof(AzureOpenAITextToAudioService)));
+
+ this._client.AddAttribute(AIServiceExtensions.ModelIdKey, modelId);
+
+ this._modelId = modelId;
+ }
+
///
public Task> GetAudioContentsAsync(
string text,
diff --git a/dotnet/src/IntegrationTests/Agents/ChatCompletionAgentTests.cs b/dotnet/src/IntegrationTests/Agents/ChatCompletionAgentTests.cs
index 008574d147de..98ff4a96d41f 100644
--- a/dotnet/src/IntegrationTests/Agents/ChatCompletionAgentTests.cs
+++ b/dotnet/src/IntegrationTests/Agents/ChatCompletionAgentTests.cs
@@ -4,12 +4,12 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
using Microsoft.SemanticKernel.ChatCompletion;
-using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
using Microsoft.SemanticKernel.Connectors.OpenAI;
using SemanticKernel.IntegrationTests.TestSettings;
using Xunit;
@@ -43,9 +43,9 @@ public async Task AzureChatCompletionAgentAsync(string input, string expectedAns
KernelPlugin plugin = KernelPluginFactory.CreateFromType();
this._kernelBuilder.AddAzureOpenAIChatCompletion(
- configuration.ChatDeploymentName!,
- configuration.Endpoint,
- configuration.ApiKey);
+ deploymentName: configuration.ChatDeploymentName!,
+ endpoint: configuration.Endpoint,
+ credentials: new AzureCliCredential());
if (useAutoFunctionTermination)
{
@@ -107,7 +107,7 @@ public async Task AzureChatCompletionStreamingAsync()
this._kernelBuilder.AddAzureOpenAIChatCompletion(
configuration.ChatDeploymentName!,
configuration.Endpoint,
- configuration.ApiKey);
+ new AzureCliCredential());
this._kernelBuilder.Plugins.Add(plugin);
diff --git a/dotnet/src/IntegrationTests/Agents/MixedAgentTests.cs b/dotnet/src/IntegrationTests/Agents/MixedAgentTests.cs
index 35d68e550dd6..77f4f1f3bd5f 100644
--- a/dotnet/src/IntegrationTests/Agents/MixedAgentTests.cs
+++ b/dotnet/src/IntegrationTests/Agents/MixedAgentTests.cs
@@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Text;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
@@ -55,7 +56,7 @@ public async Task AzureOpenAIMixedAgentAsync()
// Arrange, Act & Assert
await this.VerifyAgentExecutionAsync(
this.CreateChatCompletionKernel(azureOpenAISettings),
- OpenAIClientProvider.ForAzureOpenAI(azureOpenAISettings.ApiKey, new Uri(azureOpenAISettings.Endpoint)),
+ OpenAIClientProvider.ForAzureOpenAI(new AzureCliCredential(), new Uri(azureOpenAISettings.Endpoint)),
azureOpenAISettings.ChatDeploymentName!);
}
@@ -120,9 +121,9 @@ private Kernel CreateChatCompletionKernel(AzureOpenAIConfiguration configuration
IKernelBuilder kernelBuilder = Kernel.CreateBuilder();
kernelBuilder.AddAzureOpenAIChatCompletion(
- configuration.ChatDeploymentName!,
- configuration.Endpoint,
- configuration.ApiKey);
+ deploymentName: configuration.ChatDeploymentName!,
+ endpoint: configuration.Endpoint,
+ credentials: new AzureCliCredential());
return kernelBuilder.Build();
}
diff --git a/dotnet/src/IntegrationTests/Agents/OpenAIAssistantAgentTests.cs b/dotnet/src/IntegrationTests/Agents/OpenAIAssistantAgentTests.cs
index 0e5756ff2fcd..62388488d483 100644
--- a/dotnet/src/IntegrationTests/Agents/OpenAIAssistantAgentTests.cs
+++ b/dotnet/src/IntegrationTests/Agents/OpenAIAssistantAgentTests.cs
@@ -4,6 +4,7 @@
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents;
@@ -55,7 +56,7 @@ public async Task AzureOpenAIAssistantAgentAsync(string input, string expectedAn
Assert.NotNull(azureOpenAIConfiguration);
await this.ExecuteAgentAsync(
- OpenAIClientProvider.ForAzureOpenAI(azureOpenAIConfiguration.ApiKey, new Uri(azureOpenAIConfiguration.Endpoint)),
+ OpenAIClientProvider.ForAzureOpenAI(new AzureCliCredential(), new Uri(azureOpenAIConfiguration.Endpoint)),
azureOpenAIConfiguration.ChatDeploymentName!,
input,
expectedAnswerContains);
@@ -91,7 +92,7 @@ public async Task AzureOpenAIAssistantAgentStreamingAsync(string input, string e
Assert.NotNull(azureOpenAIConfiguration);
await this.ExecuteStreamingAgentAsync(
- OpenAIClientProvider.ForAzureOpenAI(azureOpenAIConfiguration.ApiKey, new Uri(azureOpenAIConfiguration.Endpoint)),
+ OpenAIClientProvider.ForAzureOpenAI(new AzureCliCredential(), new Uri(azureOpenAIConfiguration.Endpoint)),
azureOpenAIConfiguration.ChatDeploymentName!,
input,
expectedAnswerContains);
diff --git a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIAudioToTextTests.cs b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIAudioToTextTests.cs
index e155f6159c9a..13275f8b85bf 100644
--- a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIAudioToTextTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIAudioToTextTests.cs
@@ -3,6 +3,7 @@
using System;
using System.IO;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.AudioToText;
@@ -33,9 +34,9 @@ public async Task AzureOpenAIAudioToTextTestAsync()
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIAudioToText(
- azureOpenAIConfiguration.DeploymentName,
- azureOpenAIConfiguration.Endpoint,
- azureOpenAIConfiguration.ApiKey)
+ deploymentName: azureOpenAIConfiguration.DeploymentName,
+ endpoint: azureOpenAIConfiguration.Endpoint,
+ credentials: new AzureCliCredential())
.Build();
var service = kernel.GetRequiredService();
diff --git a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_FunctionCallingTests.cs b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionFunctionCallingTests.cs
similarity index 99%
rename from dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_FunctionCallingTests.cs
rename to dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionFunctionCallingTests.cs
index aec7320867d2..9c9c0753d079 100644
--- a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_FunctionCallingTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionFunctionCallingTests.cs
@@ -7,6 +7,7 @@
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
@@ -865,7 +866,6 @@ private Kernel CreateAndInitializeKernel(bool importHelperPlugin = false)
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get();
Assert.NotNull(azureOpenAIConfiguration);
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
- Assert.NotNull(azureOpenAIConfiguration.ApiKey);
Assert.NotNull(azureOpenAIConfiguration.Endpoint);
var kernelBuilder = base.CreateKernelBuilder();
@@ -874,7 +874,7 @@ private Kernel CreateAndInitializeKernel(bool importHelperPlugin = false)
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
modelId: azureOpenAIConfiguration.ChatModelId,
endpoint: azureOpenAIConfiguration.Endpoint,
- apiKey: azureOpenAIConfiguration.ApiKey);
+ credentials: new AzureCliCredential());
var kernel = kernelBuilder.Build();
diff --git a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_NonStreamingTests.cs b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionNonStreamingTests.cs
similarity index 98%
rename from dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_NonStreamingTests.cs
rename to dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionNonStreamingTests.cs
index a463410765f5..808227a40a11 100644
--- a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_NonStreamingTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionNonStreamingTests.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
@@ -147,7 +148,6 @@ private Kernel CreateAndInitializeKernel()
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get();
Assert.NotNull(azureOpenAIConfiguration);
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
- Assert.NotNull(azureOpenAIConfiguration.ApiKey);
Assert.NotNull(azureOpenAIConfiguration.Endpoint);
var kernelBuilder = base.CreateKernelBuilder();
@@ -156,7 +156,7 @@ private Kernel CreateAndInitializeKernel()
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
modelId: azureOpenAIConfiguration.ChatModelId,
endpoint: azureOpenAIConfiguration.Endpoint,
- apiKey: azureOpenAIConfiguration.ApiKey);
+ credentials: new AzureCliCredential());
return kernelBuilder.Build();
}
diff --git a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_StreamingTests.cs b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionStreamingTests.cs
similarity index 98%
rename from dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_StreamingTests.cs
rename to dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionStreamingTests.cs
index 5fc0e7e0cad7..85d8785e829a 100644
--- a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletion_StreamingTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionStreamingTests.cs
@@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
@@ -148,7 +149,6 @@ private Kernel CreateAndInitializeKernel()
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get();
Assert.NotNull(azureOpenAIConfiguration);
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
- Assert.NotNull(azureOpenAIConfiguration.ApiKey);
Assert.NotNull(azureOpenAIConfiguration.Endpoint);
var kernelBuilder = base.CreateKernelBuilder();
@@ -157,7 +157,7 @@ private Kernel CreateAndInitializeKernel()
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
modelId: azureOpenAIConfiguration.ChatModelId,
endpoint: azureOpenAIConfiguration.Endpoint,
- apiKey: azureOpenAIConfiguration.ApiKey);
+ credentials: new AzureCliCredential());
return kernelBuilder.Build();
}
diff --git a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionTests.cs b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionTests.cs
index 7d47ee0f45e0..2f0dd43e8b88 100644
--- a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAIChatCompletionTests.cs
@@ -8,6 +8,7 @@
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Http.Resilience;
@@ -232,7 +233,6 @@ private Kernel CreateAndInitializeKernel(HttpClient? httpClient = null)
var azureOpenAIConfiguration = this._configuration.GetSection("AzureOpenAI").Get();
Assert.NotNull(azureOpenAIConfiguration);
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
- Assert.NotNull(azureOpenAIConfiguration.ApiKey);
Assert.NotNull(azureOpenAIConfiguration.Endpoint);
Assert.NotNull(azureOpenAIConfiguration.ServiceId);
@@ -242,7 +242,7 @@ private Kernel CreateAndInitializeKernel(HttpClient? httpClient = null)
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
modelId: azureOpenAIConfiguration.ChatModelId,
endpoint: azureOpenAIConfiguration.Endpoint,
- apiKey: azureOpenAIConfiguration.ApiKey,
+ credentials: new AzureCliCredential(),
serviceId: azureOpenAIConfiguration.ServiceId,
httpClient: httpClient);
diff --git a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextEmbeddingTests.cs b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextEmbeddingTests.cs
index 20f9851a5ad7..3e459e6917c5 100644
--- a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextEmbeddingTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextEmbeddingTests.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel.Connectors.AzureOpenAI;
using Microsoft.SemanticKernel.Embeddings;
@@ -24,9 +25,9 @@ public async Task AzureOpenAITestAsync(string testInputString)
{
// Arrange
var embeddingGenerator = new AzureOpenAITextEmbeddingGenerationService(
- this._azureOpenAIConfiguration.DeploymentName,
- this._azureOpenAIConfiguration.Endpoint,
- this._azureOpenAIConfiguration.ApiKey);
+ deploymentName: this._azureOpenAIConfiguration.DeploymentName,
+ endpoint: this._azureOpenAIConfiguration.Endpoint,
+ credential: new AzureCliCredential());
// Act
var singleResult = await embeddingGenerator.GenerateEmbeddingAsync(testInputString);
@@ -46,9 +47,9 @@ public async Task AzureOpenAIWithDimensionsAsync(int? dimensions, int expectedVe
const string TestInputString = "test sentence";
var embeddingGenerator = new AzureOpenAITextEmbeddingGenerationService(
- "text-embedding-3-large",
- this._azureOpenAIConfiguration.Endpoint,
- this._azureOpenAIConfiguration.ApiKey,
+ deploymentName: "text-embedding-3-large",
+ endpoint: this._azureOpenAIConfiguration.Endpoint,
+ credential: new AzureCliCredential(),
dimensions: dimensions);
// Act
diff --git a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToAudioTests.cs b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToAudioTests.cs
index c50ce2478001..881daf5fe3ba 100644
--- a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToAudioTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToAudioTests.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.TextToAudio;
@@ -27,9 +28,9 @@ public async Task AzureOpenAITextToAudioTestAsync()
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAITextToAudio(
- azureOpenAIConfiguration.DeploymentName,
- azureOpenAIConfiguration.Endpoint,
- azureOpenAIConfiguration.ApiKey)
+ deploymentName: azureOpenAIConfiguration.DeploymentName,
+ endpoint: azureOpenAIConfiguration.Endpoint,
+ credential: new AzureCliCredential())
.Build();
var service = kernel.GetRequiredService();
diff --git a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToImageTests.cs b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToImageTests.cs
index 1374ed860f2f..4b2b65dd5417 100644
--- a/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToImageTests.cs
+++ b/dotnet/src/IntegrationTests/Connectors/AzureOpenAI/AzureOpenAITextToImageTests.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.TextToImage;
@@ -26,7 +27,10 @@ public async Task ItCanReturnImageUrlAsync()
Assert.NotNull(configuration);
var kernel = Kernel.CreateBuilder()
- .AddAzureOpenAITextToImage(configuration.DeploymentName, configuration.Endpoint, configuration.ApiKey)
+ .AddAzureOpenAITextToImage(
+ deploymentName: configuration.DeploymentName,
+ endpoint: configuration.Endpoint,
+ credentials: new AzureCliCredential())
.Build();
var service = kernel.GetRequiredService();
diff --git a/dotnet/src/IntegrationTests/Planners/Handlebars/HandlebarsPlannerTests.cs b/dotnet/src/IntegrationTests/Planners/Handlebars/HandlebarsPlannerTests.cs
index bae2d4b98742..b7859de35937 100644
--- a/dotnet/src/IntegrationTests/Planners/Handlebars/HandlebarsPlannerTests.cs
+++ b/dotnet/src/IntegrationTests/Planners/Handlebars/HandlebarsPlannerTests.cs
@@ -3,6 +3,7 @@
using System;
using System.ComponentModel;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
@@ -117,7 +118,7 @@ private Kernel InitializeKernel(bool useEmbeddings = false)
deploymentName: azureOpenAIConfiguration.ChatDeploymentName!,
modelId: azureOpenAIConfiguration.ChatModelId,
endpoint: azureOpenAIConfiguration.Endpoint,
- apiKey: azureOpenAIConfiguration.ApiKey);
+ credentials: new AzureCliCredential());
if (useEmbeddings)
{
@@ -125,7 +126,7 @@ private Kernel InitializeKernel(bool useEmbeddings = false)
deploymentName: azureOpenAIEmbeddingsConfiguration.DeploymentName,
modelId: azureOpenAIEmbeddingsConfiguration.EmbeddingModelId,
endpoint: azureOpenAIEmbeddingsConfiguration.Endpoint,
- apiKey: azureOpenAIEmbeddingsConfiguration.ApiKey);
+ credential: new AzureCliCredential());
}
return builder.Build();
diff --git a/dotnet/src/IntegrationTests/PromptTests.cs b/dotnet/src/IntegrationTests/PromptTests.cs
index 4649b7b47fcd..4435fa9a0133 100644
--- a/dotnet/src/IntegrationTests/PromptTests.cs
+++ b/dotnet/src/IntegrationTests/PromptTests.cs
@@ -4,6 +4,7 @@
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
+using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
@@ -77,13 +78,12 @@ private void ConfigureAzureOpenAI(IKernelBuilder kernelBuilder)
Assert.NotNull(azureOpenAIConfiguration);
Assert.NotNull(azureOpenAIConfiguration.ChatDeploymentName);
Assert.NotNull(azureOpenAIConfiguration.Endpoint);
- Assert.NotNull(azureOpenAIConfiguration.ApiKey);
Assert.NotNull(azureOpenAIConfiguration.ServiceId);
kernelBuilder.AddAzureOpenAIChatCompletion(
deploymentName: azureOpenAIConfiguration.ChatDeploymentName,
endpoint: azureOpenAIConfiguration.Endpoint,
- apiKey: azureOpenAIConfiguration.ApiKey,
+ credentials: new AzureCliCredential(),
serviceId: azureOpenAIConfiguration.ServiceId);
}
#endregion
diff --git a/dotnet/src/IntegrationTests/README.md b/dotnet/src/IntegrationTests/README.md
index 85a997bbea9a..09a04af158e7 100644
--- a/dotnet/src/IntegrationTests/README.md
+++ b/dotnet/src/IntegrationTests/README.md
@@ -46,27 +46,22 @@ dotnet user-secrets set "AzureOpenAI:ServiceId" "azure-gpt-35-turbo-instruct"
dotnet user-secrets set "AzureOpenAI:DeploymentName" "gpt-35-turbo-instruct"
dotnet user-secrets set "AzureOpenAI:ChatDeploymentName" "gpt-4"
dotnet user-secrets set "AzureOpenAI:Endpoint" "https://contoso.openai.azure.com/"
-dotnet user-secrets set "AzureOpenAI:ApiKey" "..."
dotnet user-secrets set "AzureOpenAIEmbeddings:ServiceId" "azure-text-embedding-ada-002"
dotnet user-secrets set "AzureOpenAIEmbeddings:DeploymentName" "text-embedding-ada-002"
dotnet user-secrets set "AzureOpenAIEmbeddings:Endpoint" "https://contoso.openai.azure.com/"
-dotnet user-secrets set "AzureOpenAIEmbeddings:ApiKey" "..."
dotnet user-secrets set "AzureOpenAIAudioToText:ServiceId" "azure-audio-to-text"
dotnet user-secrets set "AzureOpenAIAudioToText:DeploymentName" "whisper-1"
dotnet user-secrets set "AzureOpenAIAudioToText:Endpoint" "https://contoso.openai.azure.com/"
-dotnet user-secrets set "AzureOpenAIAudioToText:ApiKey" "..."
dotnet user-secrets set "AzureOpenAITextToAudio:ServiceId" "azure-text-to-audio"
dotnet user-secrets set "AzureOpenAITextToAudio:DeploymentName" "tts-1"
dotnet user-secrets set "AzureOpenAITextToAudio:Endpoint" "https://contoso.openai.azure.com/"
-dotnet user-secrets set "AzureOpenAITextToAudio:ApiKey" "..."
dotnet user-secrets set "AzureOpenAITextToImage:ServiceId" "azure-text-to-image"
dotnet user-secrets set "AzureOpenAITextToImage:DeploymentName" "dall-e-3"
dotnet user-secrets set "AzureOpenAITextToImage:Endpoint" "https://contoso.openai.azure.com/"
-dotnet user-secrets set "AzureOpenAITextToImage:ApiKey" "..."
dotnet user-secrets set "MistralAI:ChatModel" "mistral-large-latest"
dotnet user-secrets set "MistralAI:EmbeddingModel" "mistral-embed"
diff --git a/dotnet/src/IntegrationTests/TestSettings/AzureOpenAIConfiguration.cs b/dotnet/src/IntegrationTests/TestSettings/AzureOpenAIConfiguration.cs
index e530110f9322..21e76b25ebdb 100644
--- a/dotnet/src/IntegrationTests/TestSettings/AzureOpenAIConfiguration.cs
+++ b/dotnet/src/IntegrationTests/TestSettings/AzureOpenAIConfiguration.cs
@@ -6,7 +6,7 @@ namespace SemanticKernel.IntegrationTests.TestSettings;
[SuppressMessage("Performance", "CA1812:Internal class that is apparently never instantiated",
Justification = "Configuration classes are instantiated through IConfiguration.")]
-internal sealed class AzureOpenAIConfiguration(string serviceId, string deploymentName, string endpoint, string apiKey, string? chatDeploymentName = null, string? modelId = null, string? chatModelId = null, string? embeddingModelId = null)
+internal sealed class AzureOpenAIConfiguration(string serviceId, string deploymentName, string endpoint, string? apiKey = null, string? chatDeploymentName = null, string? modelId = null, string? chatModelId = null, string? embeddingModelId = null)
{
public string ServiceId { get; set; } = serviceId;
@@ -22,5 +22,5 @@ internal sealed class AzureOpenAIConfiguration(string serviceId, string deployme
public string Endpoint { get; set; } = endpoint;
- public string ApiKey { get; set; } = apiKey;
+ public string? ApiKey { get; set; } = apiKey;
}
diff --git a/dotnet/src/IntegrationTests/testsettings.json b/dotnet/src/IntegrationTests/testsettings.json
index 95c4fd2d7f3e..e4bd00c302b6 100644
--- a/dotnet/src/IntegrationTests/testsettings.json
+++ b/dotnet/src/IntegrationTests/testsettings.json
@@ -11,11 +11,10 @@
"ApiKey": ""
},
"AzureOpenAI": {
- "ServiceId": "azure-gpt-35-turbo-instruct",
+ "ServiceId": "azure-gpt",
"DeploymentName": "gpt-35-turbo-instruct",
"ChatDeploymentName": "gpt-4o",
- "Endpoint": "",
- "ApiKey": ""
+ "Endpoint": ""
},
"OpenAIEmbeddings": {
"ServiceId": "text-embedding-ada-002",
@@ -25,8 +24,7 @@
"AzureOpenAIEmbeddings": {
"ServiceId": "azure-text-embedding-ada-002",
"DeploymentName": "ada-002",
- "Endpoint": "",
- "ApiKey": ""
+ "Endpoint": ""
},
"OpenAITextToAudio": {
"ServiceId": "tts-1",
@@ -36,8 +34,7 @@
"AzureOpenAITextToAudio": {
"ServiceId": "azure-tts",
"DeploymentName": "tts",
- "Endpoint": "",
- "ApiKey": ""
+ "Endpoint": ""
},
"OpenAIAudioToText": {
"ServiceId": "whisper-1",
@@ -47,8 +44,7 @@
"AzureOpenAIAudioToText": {
"ServiceId": "azure-whisper",
"DeploymentName": "whisper",
- "Endpoint": "",
- "ApiKey": ""
+ "Endpoint": ""
},
"OpenAITextToImage": {
"ServiceId": "dall-e-2",
@@ -57,9 +53,8 @@
},
"AzureOpenAITextToImage": {
"ServiceId": "azure-dalle3",
- "DeploymentName": "dall-e-3",
- "Endpoint": "",
- "ApiKey": ""
+ "DeploymentName": "Dalle3",
+ "Endpoint": ""
},
"HuggingFace": {
"ApiKey": ""