Skip to content

Commit 2b81766

Browse files
authored
DSI-8840: Hooked up azure app configuration to aspire (#214)
1 parent e66af76 commit 2b81766

4 files changed

Lines changed: 32 additions & 5 deletions

File tree

Directory.Packages.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<PackageVersion Include="Aspire.Hosting.Redis" Version="13.4.0" />
2424
<PackageVersion Include="CommunityToolkit.Aspire.Hosting.NodeJS.Extensions" Version="9.9.0" />
2525
<!-- Dependency injection -->
26+
<PackageVersion Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" Version="8.5.0" />
2627
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.2" />
2728
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.2" />
2829
<!-- Options -->
@@ -150,4 +151,4 @@
150151
<PackageVersion Include="Testcontainers.MsSql" Version="4.3.0" />
151152
<PackageVersion Include="Respawn" Version="7.0.0" />
152153
</ItemGroup>
153-
</Project>
154+
</Project>

src/Dfe.SignIn.AppHost/AppHost.cs

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
11
using System.Reflection;
2+
using Azure.Identity;
23
using Dfe.SignIn.AppHost;
34
using Microsoft.Extensions.Configuration;
5+
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
46

57
var builder = DistributedApplication.CreateBuilder(args);
8+
9+
if (!string.IsNullOrEmpty(builder.Configuration.GetConnectionString("AppConfiguration"))) {
10+
var appConfigurationTag = builder.Configuration["AppConfiguration:Tag"];
11+
if (string.IsNullOrEmpty(appConfigurationTag)) {
12+
throw new ArgumentNullException("AppConfiguration Tag missing");
13+
}
14+
builder.Configuration.AddAzureAppConfiguration(options => {
15+
options.Connect(builder.Configuration["ConnectionStrings:AppConfiguration"])
16+
.Select(KeyFilter.Any, "dev");
17+
18+
options.ConfigureKeyVault(kv => {
19+
kv.SetCredential(new DefaultAzureCredential());
20+
});
21+
});
22+
}
23+
624
builder.Configuration.AddUserSecrets(Assembly.GetExecutingAssembly(), optional: true, reloadOnChange: true);
725

826
#pragma warning disable ASPIRECERTIFICATES001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
@@ -41,6 +59,7 @@
4159
var selectOrgConfig = builder.Configuration.GetSection("SelectOrganisation");
4260
var internalApiConfig = builder.Configuration.GetSection("InternalApiClient");
4361
var efConfig = builder.Configuration.GetSection("EntityFramework");
62+
var assets = builder.Configuration.GetSection("Assets");
4463

4564
var dotNetComponents = builder.Configuration.GetSection("Components:DotNet");
4665
var nodeComponents = builder.Configuration.GetSection("Components:Node");
@@ -52,6 +71,8 @@
5271
.WithEnvironment("GovNotify__ApiKey", govNotifyConfig["ApiKey"])
5372
.WithEnvironment("RaiseSupportTicketByEmail__SupportEmailAddress", supportEmailConfig["SupportEmailAddress"])
5473
.WithEnvironment("RaiseSupportTicketByEmail__EmailTemplateId", supportEmailConfig["EmailTemplateId"])
74+
.WithEnvironment("Assets__BaseAddress", assets["BaseAddress"])
75+
.WithEnvironment("Assets__FrontendVersion", assets["FrontendVersion"])
5576
.WaitFor(frontend)
5677
.WaitFor(redis);
5778
}
@@ -66,6 +87,7 @@
6687
.WithEnvironment("EntityFramework__Organisations__Name", efConfig["Organisations:Name"])
6788
.WithEnvironment("EntityFramework__Organisations__Username", efConfig["Organisations:Username"])
6889
.WithEnvironment("EntityFramework__Organisations__Password", efConfig["Organisations:Password"])
90+
.WithEnvironment("PublicApiSecretEncryption__Key", publicApiSecretConfig["Key"])
6991
.WithEnvironment("InternalApiClient__ClientId", internalApiConfig["ClientId"])
7092
.WithEnvironment("InternalApiClient__ClientSecret", internalApiConfig["ClientSecret"])
7193
.WithEnvironment("InternalApiClient__Tenant", internalApiConfig["Tenant"])
@@ -95,6 +117,8 @@
95117
.WithEnvironment("ExternalId__TenantId", externalIdConfig["TenantId"])
96118
.WithEnvironment("Session__DurationInMinutes", sessionConfig["DurationInMinutes"])
97119
.WithEnvironment("Session__NotifyRemainingMinutes", sessionConfig["NotifyRemainingMinutes"])
120+
.WithEnvironment("Assets__BaseAddress", assets["BaseAddress"])
121+
.WithEnvironment("Assets__FrontendVersion", assets["FrontendVersion"])
98122
.WaitFor(frontend)
99123
.WaitFor(redis);
100124
}
@@ -154,6 +178,7 @@
154178
.WaitForIfPresent(interactor);
155179
}
156180

157-
builder.AddExecutable("tool-tls-proxy", "pwsh", "../../", "-Command", "Start-DsiTlsProxy");
158-
181+
if (nodeComponents.GetValue("Run-TlsProxy", false)) {
182+
builder.AddExecutable("tool-tls-proxy", "pwsh", "../../", "-Command", "Start-DsiTlsProxy");
183+
}
159184
await builder.Build().RunAsync();

src/Dfe.SignIn.AppHost/Dfe.SignIn.AppHost.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
<PackageReference Include="Aspire.Hosting.Redis" />
1313
<PackageReference Include="Aspire.Hosting.NodeJs" />
1414
<PackageReference Include="CommunityToolkit.Aspire.Hosting.NodeJS.Extensions" />
15-
<PackageReference Include="MessagePack" />
15+
<PackageReference Include="MessagePack" />
16+
<PackageReference Include="Microsoft.Extensions.Configuration.AzureAppConfiguration" />
1617
</ItemGroup>
1718

1819
<PropertyGroup>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Dfe.SignIn.Core.UseCases;
22

33
/// <summary>
4-
/// An empty type representing the core use cases assembly.
4+
/// An empty type representing the core use cases assembly..
55
/// </summary>
66
public static class CoreUseCasesAssembly { }

0 commit comments

Comments
 (0)