This commit is contained in:
Zeeshaun
2026-04-20 19:18:10 +00:00
parent 1005c24437
commit 8c668fa319
@@ -1,3 +1,5 @@
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Hosting;
@@ -21,10 +23,9 @@ namespace LCU.Webapps.Marketing.SPIT
builder.AddJsonFile("/app/config/workload-appsettings/appsettings.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-seq-api-key.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-primary-subscription-key.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/speech-api-key.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/speech-endpoint.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-azuread-client-id.json", optional: true, reloadOnChange: true);
builder.AddJsonFile("/vault/secrets/spit-azuread-client-secret.json", optional: true, reloadOnChange: true);
builder.AddInMemoryCollection(LoadPlainTextSpeechSecrets());
})
.ConfigureWebHostDefaults(webBuilder =>
{
@@ -32,5 +33,30 @@ namespace LCU.Webapps.Marketing.SPIT
.UseSetting(WebHostDefaults.DetailedErrorsKey, "true")
.UseSerilog();
});
private static IDictionary<string, string> LoadPlainTextSpeechSecrets()
{
var configValues = new Dictionary<string, string>();
AddSecretValue(configValues, "/vault/secrets/speech-api-key.json", "Primary:SpeechApiKey");
AddSecretValue(configValues, "/vault/secrets/speech-endpoint.json", "Primary:SpeechEndpoint");
return configValues;
}
private static void AddSecretValue(IDictionary<string, string> configValues, string path, string key)
{
if (!File.Exists(path))
{
return;
}
var value = File.ReadAllText(path)?.Trim();
if (!string.IsNullOrWhiteSpace(value))
{
configValues[key] = value;
}
}
}
}