Skip to content

Commit 737e4cf

Browse files
updated app_env
1 parent 572df9e commit 737e4cf

File tree

8 files changed

+34
-22
lines changed

8 files changed

+34
-22
lines changed

App/backend-api/Microsoft.GS.DPS.Host/AppConfiguration/AppConfiguration.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ public static void Config(IHostApplicationBuilder builder)
1212
//Read ServiceConfiguration files - appsettings.json / appsettings.Development.json
1313
//builder.Configuration.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
1414
//builder.Configuration.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true);
15-
15+
var servicesConfig = builder.Configuration.GetSection("Application:Services").Get<Services>();
16+
string appEnv = servicesConfig?.APP_ENV;
1617

1718
//Read AppConfiguration with managed Identity
1819
builder.Configuration.AddAzureAppConfiguration(options =>
1920
{
20-
options.Connect(new Uri(builder.Configuration["ConnectionStrings:AppConfig"]), AzureCredentialHelper.GetAzureCredential());
21+
options.Connect(new Uri(builder.Configuration["ConnectionStrings:AppConfig"]), AzureCredentialHelper.GetAzureCredential(appEnv));
2122
});
2223

2324
//Read ServiceConfiguration

App/backend-api/Microsoft.GS.DPS.Host/AppConfiguration/Services.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public class Services
66
public KernelMemoryConfig KernelMemory { get; set; }
77
public PersistentStorageConfig PersistentStorage { get; set; }
88
public AzureAISearchConfig AzureAISearch { get; set; }
9+
public string APP_ENV { get; set; }
910

1011
public class AzureAISearchConfig
1112
{

App/backend-api/Microsoft.GS.DPS.Host/Helpers/azure_credential_utils.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ namespace Microsoft.GS.DPSHost.Helpers
77
{
88
public static class AzureCredentialHelper
99
{
10-
public static TokenCredential GetAzureCredential(string clientId = null)
10+
public static TokenCredential GetAzureCredential(string appEnv = "prod", string clientId = null)
1111
{
12-
var env = Environment.GetEnvironmentVariable("APP_ENV") ?? "prod";
12+
//var env = Environment.GetEnvironmentVariable("APP_ENV") ?? "prod";
13+
Console.WriteLine($"Current APP_ENV: {appEnv}");
1314

14-
if (string.Equals(env, "dev", StringComparison.OrdinalIgnoreCase))
15+
if (string.Equals(appEnv, "dev", StringComparison.OrdinalIgnoreCase))
1516
{
1617
return new DefaultAzureCredential(); // For local development
1718
}
@@ -23,9 +24,9 @@ public static TokenCredential GetAzureCredential(string clientId = null)
2324
}
2425
}
2526

26-
public static Task<TokenCredential> GetAzureCredentialAsync(string clientId = null)
27+
public static Task<TokenCredential> GetAzureCredentialAsync(string appEnv = "prod", string clientId = null)
2728
{
28-
return Task.FromResult(GetAzureCredential(clientId));
29+
return Task.FromResult(GetAzureCredential(appEnv, clientId));
2930
}
3031
}
3132
}

App/backend-api/Microsoft.GS.DPS.Host/appsettings.json

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,16 @@
2828
}
2929
},
3030
"Services": {
31-
"CognitiveService": {
32-
"DocumentIntelligence": {
33-
"Endpoint": "",
34-
"APIKey": ""
35-
}
36-
},
37-
"KernelMemory": {
38-
"Endpoint": ""
39-
}
31+
"CognitiveService": {
32+
"DocumentIntelligence": {
33+
"Endpoint": "",
34+
"APIKey": ""
35+
}
36+
},
37+
"KernelMemory": {
38+
"Endpoint": ""
39+
},
40+
"APP_ENV": "prod"
4041
}
4142
}
4243
}

App/kernel-memory/Helpers/azure_credential_utils.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
using System;
1+
// Copyright (c) Microsoft. All rights reserved.
2+
using System;
23
using System.Threading.Tasks;
34
using Azure.Core;
45
using Azure.Identity;
56
namespace Helpers;
67

7-
public static class azure_credential_utils
8+
public class azure_credential_utils
89
{
910
public static TokenCredential GetAzureCredential(string clientId = null)
1011
{
11-
var env = Environment.GetEnvironmentVariable("APP_ENV") ?? "prod";
12+
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production";
1213

13-
if (string.Equals(env, "dev", StringComparison.OrdinalIgnoreCase))
14+
if (string.Equals(env, "Development", StringComparison.OrdinalIgnoreCase))
1415
{
1516
return new DefaultAzureCredential(); // For local development
1617
}

App/kernel-memory/infra/modules/container-app.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,10 @@ resource kmService 'Microsoft.App/containerApps@2023-05-01' = {
172172
name: 'KernelMemory__Services__AzureAIDocIntel__Endpoint'
173173
value: AzureAIDocIntel_Endpoint
174174
}
175+
{
176+
name: 'APP_ENV'
177+
value: 'prod'
178+
}
175179
]
176180
}
177181
]

App/kernel-memory/service/Service/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@
465465
"MemoryTableName": "KMMemories",
466466
"EmbeddingsTableName": "KMEmbeddings",
467467
"TagsTableName": "KMMemoriesTags"
468-
}
468+
},
469+
"APP_ENV": "prod"
469470
}
470471
}
471472
}

Deployment/appconfig/aiservice/appconfig.jsonl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"Application:Services:PersistentStorage:CosmosMongo:ConnectionString": "{cosmosmongo-connection-string}",
1919
"Application:Services:AzureAISearch:APIKey" : "{azureaisearch-apikey}",
2020
"Application:Services:AzureAISearch:Endpoint" : "{azureaisearch-endpoint}",
21+
"Application:Services:APP_ENV": "prod",
2122
"KernelMemory:Services:AzureAIDocIntel:APIKey": "{azureaidocintel-apikey}",
2223
"KernelMemory:Services:AzureAIDocIntel:Endpoint": "{azureaidocintel-endpoint}",
2324
"KernelMemory:Services:AzureAISearch:APIKey": "{azureaisearch-apikey}",
@@ -32,5 +33,6 @@
3233
"KernelMemory:Services:AzureOpenAIText:Deployment": "{azureopenaitext-deployment}",
3334
"KernelMemory:Services:AzureOpenAIText:Endpoint": "{azureopenaitext-endpoint}",
3435
"KernelMemory:Services:AzureQueues:Account": "{azurequeues-account}",
35-
"KernelMemory:Services:AzureQueues:ConnectionString": "{azurequeues-connection-string}"
36+
"KernelMemory:Services:AzureQueues:ConnectionString": "{azurequeues-connection-string}",
37+
"KernelMemory:Services:APP_ENV": "prod"
3638
}

0 commit comments

Comments
 (0)