forked from microsoft/dicom-server
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStartup.cs
68 lines (57 loc) · 2.77 KB
/
Startup.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// -------------------------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License (MIT). See LICENSE in the repo root for license information.
// -------------------------------------------------------------------------------------------------
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Health.Development.IdentityProvider.Registration;
using Microsoft.Health.Dicom.Core.Features.Security;
using Microsoft.Health.Dicom.Functions.Client;
namespace Microsoft.Health.Dicom.Web;
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public virtual void ConfigureServices(IServiceCollection services)
{
services.Configure<IISServerOptions>(options =>
{
// When hosted on IIS, the max request body size can not over 2GB, according to Asp.net Core bug https://github.com/dotnet/aspnetcore/issues/2711
options.MaxRequestBodySize = int.MaxValue;
});
services.AddDevelopmentIdentityProvider<DataActions>(Configuration, "DicomServer");
// The execution of IHostedServices depends on the order they are added to the dependency injection container, so we
// need to ensure that the schema is initialized before the background workers are started.
services.AddDicomServer(Configuration)
.AddBlobDataStores(Configuration)
.AddSqlServer(Configuration)
.AddKeyVaultClient(Configuration)
.AddAzureFunctionsClient(Configuration)
.AddBackgroundWorkers()
.AddHostedServices();
AddApplicationInsightsTelemetry(services);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public virtual void Configure(IApplicationBuilder app)
{
app.UseDicomServer();
app.UseDevelopmentIdentityProviderIfConfigured();
}
/// <summary>
/// Adds ApplicationInsights for telemetry and logging.
/// </summary>
private void AddApplicationInsightsTelemetry(IServiceCollection services)
{
string instrumentationKey = Configuration["ApplicationInsights:InstrumentationKey"];
if (!string.IsNullOrWhiteSpace(instrumentationKey))
{
var connectionString = $"InstrumentationKey={instrumentationKey}";
services.AddApplicationInsightsTelemetry(aiOptions => aiOptions.ConnectionString = connectionString);
}
}
}