Skip to content

Commit 2795a10

Browse files
committed
Add keyvalut-appinsights-docker etc
1 parent 948ada1 commit 2795a10

32 files changed

+490
-172
lines changed

Altinn.Platform.DialogportenAdapter.sln Altinn.DialogportenAdapter.sln

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DialogportenAdapter", "src\DialogportenAdapter\DialogportenAdapter.csproj", "{B1D4ADAD-3176-4C3E-A0D2-E313792587CA}"
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.8.34322.80
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DialogportenAdapter", "src\DialogportenAdapter\DialogportenAdapter.csproj", "{B1D4ADAD-3176-4C3E-A0D2-E313792587CA}"
47
EndProject
58
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{530DD6C7-2F29-4B27-9FEE-0F2612F5391B}"
69
ProjectSection(SolutionItems) = preProject
710
docker-compose.yml = docker-compose.yml
811
EndProjectSection
912
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DialogportenAdapter.Interface", "src\DialogportenAdapter.Interface\DialogportenAdapter.Interface.csproj", "{62EFCB3C-3C4D-418B-A4DD-DC1011AF8469}"
13+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DialogportenAdapter.Interface", "src\DialogportenAdapter.Interface\DialogportenAdapter.Interface.csproj", "{62EFCB3C-3C4D-418B-A4DD-DC1011AF8469}"
1114
EndProject
12-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Altinn.Platform.DialogportenAdapter.UnitTest", "test\UnitTest\Altinn.Platform.DialogportenAdapter.UnitTest.csproj", "{097FDDA8-CBDE-4C68-92C1-DBD9A36FD6D8}"
15+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.DialogportenAdapter.UnitTest", "test\UnitTest\Altinn.DialogportenAdapter.UnitTest.csproj", "{097FDDA8-CBDE-4C68-92C1-DBD9A36FD6D8}"
1316
EndProject
14-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Altinn.Platform.DialogportenAdapter.WebApi", "src\Altinn.Platform.DialogportenAdapter.WebApi\Altinn.Platform.DialogportenAdapter.WebApi.csproj", "{3FB848BE-8FD5-4DA2-BC83-EE7CBA8359E3}"
17+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Altinn.DialogportenAdapter.WebApi", "src\Altinn.DialogportenAdapter.WebApi\Altinn.DialogportenAdapter.WebApi.csproj", "{3FB848BE-8FD5-4DA2-BC83-EE7CBA8359E3}"
1518
EndProject
1619
Global
1720
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -36,6 +39,7 @@ Global
3639
{3FB848BE-8FD5-4DA2-BC83-EE7CBA8359E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
3740
{3FB848BE-8FD5-4DA2-BC83-EE7CBA8359E3}.Release|Any CPU.Build.0 = Release|Any CPU
3841
EndGlobalSection
39-
GlobalSection(NestedProjects) = preSolution
42+
GlobalSection(SolutionProperties) = preSolution
43+
HideSolutionNode = FALSE
4044
EndGlobalSection
4145
EndGlobal

Dockerfile

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0.102-alpine3.20 AS build
2+
WORKDIR /app
3+
4+
# Copy csproj and restore as distinct layers
5+
COPY src/Altinn.DialogportenAdapter.WebApi/*.csproj ./src/Altinn.DialogportenAdapter.WebApi/
6+
RUN dotnet restore ./src/Altinn.DialogportenAdapter.WebApi/Altinn.DialogportenAdapter.WebApi.csproj
7+
8+
# Copy everything else and build
9+
COPY src ./src
10+
RUN dotnet build -c Release -o out ./src/Altinn.DialogportenAdapter.WebApi/Altinn.DialogportenAdapter.WebApi.csproj
11+
12+
# Build runtime image
13+
FROM mcr.microsoft.com/dotnet/aspnet:9.0.1-alpine3.20 AS final
14+
WORKDIR /app
15+
EXPOSE 5011
16+
17+
COPY --from=build /app/out .
18+
19+
RUN addgroup -g 3000 dotnet && adduser -u 1000 -G dotnet -D -s /bin/false dotnet
20+
USER dotnet
21+
RUN mkdir /tmp/logtelemetry
22+
23+
ENTRYPOINT [ "dotnet", "Altinn.DialogportenAdapter.WebApi.dll" ]

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
services:
22
dialogportenadapter:
33
image: dialogportenadapter
4+
ports:
5+
- 8080:5011
46
build:
57
context: .
6-
dockerfile: src/DialogportenAdapter/Dockerfile
8+
dockerfile: Dockerfile

src/Altinn.Platform.DialogportenAdapter.WebApi/Altinn.Platform.DialogportenAdapter.WebApi.csproj src/Altinn.DialogportenAdapter.WebApi/Altinn.DialogportenAdapter.WebApi.csproj

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
44
<TargetFramework>net9.0</TargetFramework>
@@ -9,7 +9,11 @@
99

1010
<ItemGroup>
1111
<PackageReference Include="Altinn.ApiClients.Maskinporten" Version="9.2.1" />
12+
<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.3.2" />
1213
<PackageReference Include="Altinn.Platform.Storage.Interface" Version="4.0.4" />
14+
<PackageReference Include="Azure.Identity" Version="1.13.2" />
15+
<PackageReference Include="JWTCookieAuthentication" Version="4.0.1" />
16+
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
1317
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="9.0.0"/>
1418
<PackageReference Include="Refit.HttpClientFactory" Version="8.0.0" />
1519
</ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Net;
22
using Refit;
33

4-
namespace Altinn.Platform.DialogportenAdapter.WebApi.Common;
4+
namespace Altinn.DialogportenAdapter.WebApi.Common;
55

66
internal static class ApiResponseExtensions
77
{
@@ -12,18 +12,18 @@ internal static class ApiResponseExtensions
1212
{
1313
return default;
1414
}
15-
15+
1616
return response.IsSuccessful
1717
? response.Content
1818
: throw response.Error;
1919
}
20-
20+
2121
public static async Task<T> EnsureSuccess<T>(this Task<T> responseTask)
2222
where T : IApiResponse
2323
{
2424
var response = await responseTask;
25-
return response.IsSuccessful
26-
? response
25+
return response.IsSuccessful
26+
? response
2727
: throw response.Error;
2828
}
2929
}

src/Altinn.Platform.DialogportenAdapter.WebApi/Common/Constants.cs src/Altinn.DialogportenAdapter.WebApi/Common/Constants.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using System.Collections.Immutable;
22
using Altinn.Platform.Storage.Interface.Enums;
33

4-
namespace Altinn.Platform.DialogportenAdapter.WebApi.Common;
4+
namespace Altinn.DialogportenAdapter.WebApi.Common;
55

66
public static class Constants
77
{

src/Altinn.Platform.DialogportenAdapter.WebApi/Common/GuidExtensions.cs src/Altinn.DialogportenAdapter.WebApi/Common/GuidExtensions.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Altinn.Platform.DialogportenAdapter.WebApi.Common;
1+
namespace Altinn.DialogportenAdapter.WebApi.Common;
22

33
internal static class GuidExtensions
44
{
@@ -12,18 +12,18 @@ public static Guid ToVersion7(this Guid guid, DateTimeOffset timestamp)
1212
var unixTimestampMillis = timestamp.ToUnixTimeMilliseconds();
1313

1414
// Write the timestamp (48 bits) into the UUID buffer
15-
uuidBytes[0] = (byte)((unixTimestampMillis >> 40) & 0xFF);
16-
uuidBytes[1] = (byte)((unixTimestampMillis >> 32) & 0xFF);
17-
uuidBytes[2] = (byte)((unixTimestampMillis >> 24) & 0xFF);
18-
uuidBytes[3] = (byte)((unixTimestampMillis >> 16) & 0xFF);
19-
uuidBytes[4] = (byte)((unixTimestampMillis >> 8) & 0xFF);
15+
uuidBytes[0] = (byte)(unixTimestampMillis >> 40 & 0xFF);
16+
uuidBytes[1] = (byte)(unixTimestampMillis >> 32 & 0xFF);
17+
uuidBytes[2] = (byte)(unixTimestampMillis >> 24 & 0xFF);
18+
uuidBytes[3] = (byte)(unixTimestampMillis >> 16 & 0xFF);
19+
uuidBytes[4] = (byte)(unixTimestampMillis >> 8 & 0xFF);
2020
uuidBytes[5] = (byte)(unixTimestampMillis & 0xFF);
2121

2222
// Set the version to 7 (4 high bits of the 7th byte)
23-
uuidBytes[6] = (byte)((uuidBytes[6] & 0x0F) | 0x70);
23+
uuidBytes[6] = (byte)(uuidBytes[6] & 0x0F | 0x70);
2424

2525
// Set the variant to RFC 4122 (2 most significant bits of the 9th byte to 10)
26-
uuidBytes[8] = (byte)((uuidBytes[8] & 0x3F) | 0x80);
26+
uuidBytes[8] = (byte)(uuidBytes[8] & 0x3F | 0x80);
2727

2828
// Construct and return the UUID
2929
return new Guid(uuidBytes, bigEndian: true);

src/Altinn.Platform.DialogportenAdapter.WebApi/Common/MediaTypes.cs src/Altinn.DialogportenAdapter.WebApi/Common/MediaTypes.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Altinn.Platform.DialogportenAdapter.WebApi.Common;
1+
namespace Altinn.DialogportenAdapter.WebApi.Common;
22

33
public static class MediaTypes
44
{

src/Altinn.Platform.DialogportenAdapter.WebApi/Common/SpanExtensions.cs src/Altinn.DialogportenAdapter.WebApi/Common/SpanExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Altinn.Platform.DialogportenAdapter.WebApi.Common;
1+
namespace Altinn.DialogportenAdapter.WebApi.Common;
22

33
internal static class SpanExtensions
44
{
@@ -21,7 +21,7 @@ public static bool TryCopyTo(this ReadOnlySpan<char> source, Span<char> destinat
2121
offset = destination.Length;
2222
return false;
2323
}
24-
24+
2525
source.CopyTo(destination[offset..]);
2626
offset += source.Length;
2727
return true;

src/Altinn.Platform.DialogportenAdapter.WebApi/Common/TaskExtentions.cs src/Altinn.DialogportenAdapter.WebApi/Common/TaskExtentions.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using System.Runtime.CompilerServices;
22

3-
namespace Altinn.Platform.DialogportenAdapter.WebApi.Common;
3+
namespace Altinn.DialogportenAdapter.WebApi.Common;
44

5-
public static class TaskExtentions
5+
public static class TaskExtentions
66
{
77
public static TaskAwaiter<(T1, T2)> GetAwaiter<T1, T2>(
88
this (Task<T1>, Task<T2>) taskTuple)
@@ -108,9 +108,9 @@ public static Task WithAggregatedExceptions(this Task @this)
108108
.ContinueWith(
109109
continuationFunction: anteTask =>
110110
anteTask is { IsFaulted: true, Exception: not null } &&
111-
(anteTask.Exception.InnerExceptions.Count > 1
112-
|| anteTask.Exception.InnerException is AggregateException)
113-
? Task.FromException(anteTask.Exception.Flatten())
111+
(anteTask.Exception.InnerExceptions.Count > 1
112+
|| anteTask.Exception.InnerException is AggregateException)
113+
? Task.FromException(anteTask.Exception.Flatten())
114114
: anteTask,
115115
cancellationToken: CancellationToken.None,
116116
TaskContinuationOptions.ExecuteSynchronously,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using Microsoft.ApplicationInsights.Channel;
2+
using Microsoft.ApplicationInsights.Extensibility;
3+
4+
namespace Altinn.Notifications.Configuration;
5+
6+
/// <summary>
7+
/// Set up custom telemetry for Application Insights
8+
/// </summary>
9+
public class CustomTelemetryInitializer : ITelemetryInitializer
10+
{
11+
/// <summary>
12+
/// Custom TelemetryInitializer that sets some specific values for the component
13+
/// </summary>
14+
public void Initialize(ITelemetry telemetry)
15+
{
16+
if (string.IsNullOrEmpty(telemetry.Context.Cloud.RoleName))
17+
{
18+
telemetry.Context.Cloud.RoleName = "platform-dialogporten-adapter";
19+
}
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
namespace Altinn.DialogportenAdapter.WebApi.Configuration;
2+
3+
/// <summary>
4+
/// The key vault settings used to fetch certificate information from key vault
5+
/// </summary>
6+
public class KeyVaultSettings
7+
{
8+
/// <summary>
9+
/// The key vault reader client id
10+
/// </summary>
11+
public string ClientId { get; set; } = string.Empty;
12+
13+
/// <summary>
14+
/// The key vault client secret
15+
/// </summary>
16+
public string ClientSecret { get; set; } = string.Empty;
17+
18+
/// <summary>
19+
/// The key vault tenant Id
20+
/// </summary>
21+
public string TenantId { get; set; } = string.Empty;
22+
23+
/// <summary>
24+
/// The uri to the key vault
25+
/// </summary>
26+
public string SecretUri { get; set; } = string.Empty;
27+
}

src/Altinn.Platform.DialogportenAdapter.WebApi/Features/Command/Delete/DeleteDialogService.cs src/Altinn.DialogportenAdapter.WebApi/Features/Command/Delete/DeleteDialogService.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
using Altinn.Platform.DialogportenAdapter.WebApi.Infrastructure.Storage;
1+
using Altinn.DialogportenAdapter.WebApi.Infrastructure.Storage;
22

3-
namespace Altinn.Platform.DialogportenAdapter.WebApi.Features.Command.Delete;
3+
namespace Altinn.DialogportenAdapter.WebApi.Features.Command.Delete;
44

55
public record DeleteDialogDto(string InstanceId, bool Hard);
66

0 commit comments

Comments
 (0)