.Net: Remove the HTTPS validations in AzureClientCore (#11943)

### Remove HTTPS validation from `AzureClientCore` class.

We are redirecting requests internally to inject API keys securely and
keep track of token usage in a transparent way, but this involves a YARP
proxy in between certain applications and Azure OpenAI. That proxy,
being internal behind our servers, doesn't use HTTPS and it doesn't need
to use it either. The current version of Semantic Kernel throws an error
when using a HTTP endpoint. Current fixes involve a lot of additional
steps and going out of the server to come back in through our azure
gateway or adding self-generated certificates and bypassing SSL errors,
etc... This fix would be very helpful.

* Remove the `Verify.StartsWith` validation for the `endpoint` parameter
in the constructors of `AzureClientCore` class.
* Remove the test case
`ConstructorWithInvalidEndpointShouldThrowArgumentException` from
`AzureClientCoreTests` class.
* Ensure the remaining test cases do not enforce HTTPS validation.
This commit is contained in:
snakex64
2025-05-19 12:39:06 +00:00
committed by GitHub
parent 16024093b9
commit 854330ca5f
2 changed files with 0 additions and 15 deletions
@@ -43,19 +43,6 @@ public sealed class AzureClientCoreTests : IDisposable
Assert.Equal(new Uri(endpoint), azureClientCore.Endpoint);
}
[Fact]
public void ConstructorWithInvalidEndpointShouldThrowArgumentException()
{
// Arrange
var deploymentName = "test-deployment";
var invalidEndpoint = "http://invalid-endpoint";
var apiKey = "test-api-key";
// Act & Assert
Assert.Throws<ArgumentException>(() =>
new AzureClientCore(deploymentName, invalidEndpoint, apiKey, this._httpClient, this._mockLogger.Object));
}
[Fact]
public void ConstructorWithTokenCredentialShouldInitializeCorrectly()
{
@@ -52,7 +52,6 @@ internal partial class AzureClientCore : ClientCore
{
Verify.NotNullOrWhiteSpace(deploymentName);
Verify.NotNullOrWhiteSpace(endpoint);
Verify.StartsWith(endpoint, "https://", "The Azure OpenAI endpoint must start with 'https://'");
Verify.NotNullOrWhiteSpace(apiKey);
var options = GetAzureOpenAIClientOptions(httpClient, apiVersion);
@@ -85,7 +84,6 @@ internal partial class AzureClientCore : ClientCore
{
Verify.NotNullOrWhiteSpace(deploymentName);
Verify.NotNullOrWhiteSpace(endpoint);
Verify.StartsWith(endpoint, "https://", "The Azure OpenAI endpoint must start with 'https://'");
var options = GetAzureOpenAIClientOptions(httpClient, apiVersion);