Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion samples/assistant/java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-identity</artifactId>
<version>1.16.2</version>
<version>1.18.0</version>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,19 @@ sealed class AzureAISearchProvider : ISearchProvider
/// <exception cref="ArgumentNullException">Throws ArgumentNullException if logger factory is null.</exception>
public AzureAISearchProvider(IConfiguration configuration, ILoggerFactory loggerFactory, IOptions<AzureAISearchConfigOptions> azureAiSearchConfigOptions, AzureComponentFactory azureComponentFactory)
{

#if RELEASE
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS")))
{
Environment.SetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS", "prod");
}
#else
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS")))
{
Environment.SetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS", "dev");
}

#endif
this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
this.azureComponentFactory = azureComponentFactory ?? throw new ArgumentNullException(nameof(azureComponentFactory));

Expand Down Expand Up @@ -331,7 +344,7 @@ SearchClient GetSearchClient(ConnectionInfo connectionInfo)
TokenCredential GetSearchTokenCredential() =>
this.searchConnectionConfigSection.Exists()
? this.azureComponentFactory.CreateTokenCredential(this.searchConnectionConfigSection)
: new DefaultAzureCredential();
: new DefaultAzureCredential(DefaultAzureCredential.DefaultEnvironmentVariableName);

void SetConfigSectionProperties()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ public CosmosDBNoSqlSearchProvider(
AzureComponentFactory azureComponentFactory
)
{

#if RELEASE
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS")))
{
Environment.SetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS", "prod");
}
#else
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS")))
{
Environment.SetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS", "dev");
}
#endif

this.configuration =
configuration ?? throw new ArgumentNullException(nameof(configuration));
this.azureComponentFactory =
Expand Down Expand Up @@ -238,7 +251,7 @@ CosmosClient CreateCosmosClient()

return new CosmosClient(
connectionSettingValue, // This is the endpoint URI
new DefaultAzureCredential(),
new DefaultAzureCredential(DefaultAzureCredential.DefaultEnvironmentVariableName),
cosmosClientOptions
);
}
Expand Down
15 changes: 14 additions & 1 deletion src/WebJobs.Extensions.OpenAI/OpenAIClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ public OpenAIClientFactory(
AzureComponentFactory azureComponentFactory,
ILoggerFactory loggerFactory)
{

#if RELEASE
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS")))
{
Environment.SetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS", "prod");
}
#else
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS")))
{
Environment.SetEnvironmentVariable("AZURE_TOKEN_CREDENTIALS", "dev");
}
#endif

this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
this.azureComponentFactory = azureComponentFactory ?? throw new ArgumentNullException(nameof(azureComponentFactory));
this.logger = loggerFactory?.CreateLogger<OpenAIClientFactory>() ?? throw new ArgumentNullException(nameof(loggerFactory));
Expand Down Expand Up @@ -118,7 +131,7 @@ AzureOpenAIClient CreateClientFromConfigSection(string aiConnectionName)

TokenCredential tokenCredential = section.Exists() ?
this.azureComponentFactory.CreateTokenCredential(section) :
new DefaultAzureCredential();
new DefaultAzureCredential(DefaultAzureCredential.DefaultEnvironmentVariableName);
return this.CreateAzureOpenAIClientWithTokenCredential(this.aiEndpoint, tokenCredential);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<ItemGroup>
<PackageReference Include="Azure.AI.OpenAI" Version="2.1.0" />
<PackageReference Include="Azure.Data.Tables" Version="12.10.0" />
<PackageReference Include="Azure.Identity" Version="1.13.2" />
<PackageReference Include="Azure.Identity" Version="1.17.1" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.41" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.10.0" />
Expand Down