-
Notifications
You must be signed in to change notification settings - Fork 159
Important update to DAB toolkit, fixed a few things, updated many #1138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b4b47fd
b0958c7
2203104
ea315d8
a8ade1b
db49565
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,33 @@ | ||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| // Add a SQL Server container | ||
| var sqlServer = builder | ||
| .AddSqlServer("sql"); | ||
| var sqlScript = File.ReadAllText("./sql-server.sql"); | ||
|
|
||
| var sqlDatabase = sqlServer.AddDatabase("trek"); | ||
| var sqlDatabase = builder | ||
| .AddSqlServer("sql") | ||
| .WithDataVolume("trek-sql-data") | ||
| .AddDatabase("trek") | ||
JerryNixon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .WithCreationScript(sqlScript); | ||
|
|
||
| // Populate the database with the schema and data | ||
| sqlServer | ||
| .WithBindMount("./sql-server", target: "/usr/config") | ||
| .WithBindMount("../database", target: "/docker-entrypoint-initdb.d") | ||
| .WithEntrypoint("/usr/config/entrypoint.sh"); | ||
| var dabConfig = new FileInfo("./dab-config.json"); | ||
|
|
||
| // Add Data API Builder using dab-config.json | ||
| var dab = builder.AddDataAPIBuilder("dab") | ||
| .WaitFor(sqlServer) | ||
| .WithImageTag("1.7.86-rc") | ||
| .WithConfigFile(dabConfig) | ||
| .WaitFor(sqlDatabase) | ||
| .WithReference(sqlDatabase); | ||
|
|
||
| var mcp = builder | ||
| .AddMcpInspector("mcp-inspector", options => | ||
| { | ||
| options.InspectorVersion = "0.20.0"; | ||
| }) | ||
| .WithMcpServer(dab, transportType: McpTransportType.StreamableHttp) | ||
| .WithParentRelationship(dab) | ||
| .WithEnvironment("DANGEROUSLY_OMIT_AUTH", "true") | ||
| .WaitFor(dab); | ||
|
|
||
| builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Azure_DataApiBuilder_BlazorApp>("blazorApp") | ||
| .WithReference(dab); | ||
| .WithReference(dab) | ||
| .WaitFor(dab); | ||
|
|
||
| builder.Build().Run(); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| { | ||
| "$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.3.19/dab.draft.schema.json", | ||
| "$schema": "https://github.com/Azure/data-api-builder/releases/download/v1.7.86-rc/dab.draft.schema.json", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't match the container image listed, shouldn't they match? |
||
| "data-source": { | ||
| "database-type": "mssql", | ||
| "connection-string": "@env('ConnectionStrings__trek')", | ||
|
|
@@ -16,6 +16,9 @@ | |
| "path": "/graphql", | ||
| "allow-introspection": true | ||
| }, | ||
| "mcp": { | ||
| "enabled": true | ||
| }, | ||
| "host": { | ||
| "cors": { | ||
| "origins": [ | ||
|
|
||
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| // This file is used by Code Analysis to maintain SuppressMessage | ||
| // attributes that are applied to this project. | ||
| // Project-level suppressions either have no target or are given | ||
| // a specific target and scoped to a namespace, type, member, etc. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
|
|
||
| [assembly: SuppressMessage("Performance", "CA1873:Avoid potentially expensive logging", Justification = "The additional allocation cost from logging in TrekApiClient.GetSeriesAsync is acceptable for this sample Blazor application and simplifies the example code.", Scope = "member", Target = "~M:CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.BlazorApp.TrekApiClient.GetSeriesAsync~System.Threading.Tasks.Task{System.Collections.Generic.List{CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.BlazorApp.Series}}")] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,45 +1,56 @@ | ||
| using System.Net.Http; | ||
| using System.Text.Json.Serialization; | ||
| using System.Text.Json; | ||
|
|
||
| using System.Text.Json.Serialization; | ||
|
|
||
| namespace CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder.BlazorApp; | ||
|
|
||
| public class TrekApiClient | ||
| public class TrekApiClient(HttpClient httpClient, ILogger<TrekApiClient> logger) | ||
| { | ||
| private readonly HttpClient httpClient; | ||
| private readonly ILogger<TrekApiClient> logger; | ||
|
|
||
| public TrekApiClient(HttpClient httpClient, ILogger<TrekApiClient> logger) | ||
| { | ||
| this.httpClient = httpClient; | ||
| this.logger = logger; | ||
| } | ||
|
|
||
| public async Task<List<Series>> GetSeriesAsync() | ||
| { | ||
| try | ||
| var response = await httpClient.GetAsync($"api/series"); | ||
| response.EnsureSuccessStatusCode(); | ||
| var result = await response.Content.ReadFromJsonAsync<DabResponse<Series>>(); | ||
|
|
||
| if(result is null) | ||
| { | ||
| var result = await httpClient.GetFromJsonAsync<SeriesList>($"api/series"); | ||
| return result?.value ?? new List<Series>(); | ||
| logger.LogError("Failed to deserialize response from Data API Builder."); | ||
| throw new Exception("Failed to deserialize response from Data API Builder."); | ||
| } | ||
| catch (Exception ex) | ||
|
|
||
| if (result.Error is not null) | ||
| { | ||
| logger.LogError(ex, "An error occurred while fetching series."); | ||
| return new List<Series>(); | ||
| logger.LogError("API error: {Code} - {Message}", result.Error.Code, result.Error.Message); | ||
| throw new Exception($"{result.Error.Code}: {result.Error.Message}"); | ||
| } | ||
JerryNixon marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| return result.Value ?? []; | ||
| } | ||
| } | ||
|
|
||
| public class SeriesList | ||
| public class DabResponse<T> | ||
| { | ||
| public List<Series> value { get; set; } = new List<Series>(); | ||
| [JsonPropertyName("value")] | ||
| public List<T>? Value { get; set; } | ||
|
|
||
| [JsonPropertyName("nextLink")] | ||
| public string? NextLink { get; set; } | ||
|
|
||
| [JsonPropertyName("error")] | ||
| public DabError? Error { get; set; } | ||
| } | ||
|
|
||
| public class DabError | ||
| { | ||
| [JsonPropertyName("code")] | ||
| public string Code { get; set; } = string.Empty; | ||
|
|
||
| [JsonPropertyName("message")] | ||
| public string Message { get; set; } = string.Empty; | ||
|
|
||
| [JsonPropertyName("status")] | ||
| public int Status { get; set; } | ||
| } | ||
|
|
||
| public class Series | ||
| { | ||
| [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] | ||
| public int Id { get; set; } | ||
| public required string Name { get; set; } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ | |
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Aspire.Hosting" /> | ||
| <PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no more health checks? |
||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,16 @@ | ||
| namespace CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder; | ||
|
|
||
| /// <summary> | ||
| /// Container image tags for the Data API Builder container. | ||
| /// </summary> | ||
| internal static class DataApiBuilderContainerImageTags | ||
| { | ||
| /// <summary>The container registry.</summary> | ||
| public const string Registry = "mcr.microsoft.com"; | ||
|
|
||
| /// <summary>The container image name.</summary> | ||
| public const string Image = "azure-databases/data-api-builder"; | ||
| public const string Tag = "1.6.77"; | ||
|
|
||
| /// <summary>The default container image tag.</summary> | ||
| public const string Tag = "1.6.87"; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,21 @@ | ||
| namespace Aspire.Hosting.ApplicationModel; | ||
|
|
||
| /// <summary> | ||
| /// A resource that represents Data Api Builder. | ||
| /// A resource that represents Data API Builder. | ||
| /// </summary> | ||
| /// <param name="name">The name of the resource.</param> | ||
| /// <param name="entrypoint">An optional container entrypoint.</param> | ||
|
|
||
| public class DataApiBuilderContainerResource(string name, string? entrypoint = null) | ||
| public sealed class DataApiBuilderContainerResource(string name, string? entrypoint = null) | ||
| : ContainerResource(name, entrypoint), IResourceWithServiceDiscovery | ||
| { | ||
| internal const string HttpEndpointName = "http"; | ||
| internal const string HttpsEndpointName = "https"; | ||
|
|
||
| internal const int HttpEndpointPort = 5000; | ||
| internal const int HttpsEndpointPort = 5001; | ||
tommasodotNET marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private EndpointReference? _primaryEndpoint; | ||
|
|
||
| /// <summary> | ||
| /// Gets the primary HTTP endpoint for the Data API Builder container. | ||
| /// </summary> | ||
| public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, HttpEndpointName); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's revert this change as we should keep them all in sync and we haven't had time to update everything else.