-
Notifications
You must be signed in to change notification settings - Fork 332
Expand file tree
/
Copy pathapphost.cs
More file actions
73 lines (64 loc) · 2.69 KB
/
apphost.cs
File metadata and controls
73 lines (64 loc) · 2.69 KB
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
69
70
71
72
73
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#:sdk [email protected]
#:package [email protected]
#:package CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects@9.8.1-beta.420
#:package CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder@9.8.1-beta.420
#:package [email protected]
var builder = DistributedApplication.CreateBuilder(args);
var options = new
{
SqlScript = "database.sql",
SqlDatabase = "StarTrek",
DabConfig = "dab-config.json",
DabImage = "1.7.81-rc",
SqlCmdrImage = "latest"
};
var sqlServer = builder
.AddSqlServer("sql-server")
.WithDataVolume("sql-data-volume")
.WithLifetime(ContainerLifetime.Persistent);
var sqlDatabase = sqlServer
.AddDatabase("sql-database", options.SqlDatabase)
.WithCreationScript(File.ReadAllText(new FileInfo(options.SqlScript).FullName));
var dabServer = builder
.AddContainer("data-api", image: "azure-databases/data-api-builder", tag: options.DabImage)
.WithImageRegistry("mcr.microsoft.com")
.WithBindMount(source: new FileInfo(options.DabConfig).FullName, target: "/App/dab-config.json", isReadOnly: true)
.WithHttpEndpoint(targetPort: 5000, name: "http")
.WithEnvironment("MSSQL_CONNECTION_STRING", sqlDatabase)
.WithUrls(context =>
{
context.Urls.Clear();
context.Urls.Add(new() { Url = "/graphql", DisplayText = "Nitro", Endpoint = context.GetEndpoint("http") });
context.Urls.Add(new() { Url = "/swagger", DisplayText = "Swagger", Endpoint = context.GetEndpoint("http") });
context.Urls.Add(new() { Url = "/health", DisplayText = "Health", Endpoint = context.GetEndpoint("http") });
})
.WithOtlpExporter()
.WithParentRelationship(sqlDatabase)
.WithHttpHealthCheck("/health")
.WaitFor(sqlDatabase);
var sqlCommander = builder
.AddContainer("sql-cmdr", "jerrynixon/sql-commander", options.SqlCmdrImage)
.WithImageRegistry("docker.io")
.WithHttpEndpoint(targetPort: 8080, name: "http")
.WithEnvironment("ConnectionStrings__db", sqlDatabase)
.WithUrls(context =>
{
context.Urls.Clear();
context.Urls.Add(new() { Url = "/", DisplayText = "Commander", Endpoint = context.GetEndpoint("http") });
})
.WithParentRelationship(sqlDatabase)
.WithHttpHealthCheck("/health")
.WaitFor(sqlDatabase);
var mcpInspector = builder
.AddMcpInspector("mcp-inspector")
.WithMcpServer(dabServer)
.WithParentRelationship(dabServer)
.WithEnvironment("NODE_TLS_REJECT_UNAUTHORIZED", "0")
.WaitFor(dabServer)
.WithUrls(context =>
{
context.Urls.First().DisplayText = "Inspector";
});
await builder.Build().RunAsync();