diff --git a/Dockerfile b/Dockerfile index 59190b6374..21dfece640 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,6 @@ # Version values referenced from https://hub.docker.com/_/microsoft-dotnet-aspnet -FROM mcr.microsoft.com/dotnet/sdk:8.0-cbl-mariner2.0. AS build +FROM mcr.microsoft.com/dotnet/sdk:8.0-cbl-mariner2.0 AS build WORKDIR /src @@ -11,7 +11,7 @@ FROM mcr.microsoft.com/dotnet/aspnet:8.0-cbl-mariner2.0 AS runtime COPY --from=build /out /App # Add default dab-config.json to /App in the image -COPY dab-config.json /App/dab-config.json +COPY --from=build /out/dab-config.json /App/dab-config.json WORKDIR /App ENV ASPNETCORE_URLS=http://+:5000 ENTRYPOINT ["dotnet", "Azure.DataApiBuilder.Service.dll"] diff --git a/dab-config.json b/dab-config.json deleted file mode 100644 index 6c0acfebd3..0000000000 --- a/dab-config.json +++ /dev/null @@ -1,58 +0,0 @@ -{ - "$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json", - "data-source": { - "database-type": "mssql", - "connection-string": "@env('DAB_CONNSTRING')", - "options": { - "set-session-context": false - } - }, - "runtime": { - "rest": { - "enabled": true, - "path": "/api", - "request-body-strict": false - }, - "graphql": { - "enabled": true, - "path": "/graphql", - "allow-introspection": true - }, - "mcp": { - "enabled": true, - "path": "/mcp" - }, - "host": { - "cors": { - "origins": [], - "allow-credentials": false - }, - "authentication": { - "provider": "Unauthenticated" - }, - "mode": "development" - } - }, - "entities": {}, - "autoentities": { - "default": { - "template": { - "mcp": { "dml-tools": true }, - "rest": { "enabled": true }, - "graphql": { "enabled": true }, - "health": { "enabled": true }, - "cache": { - "enabled": false - } - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - "create", "read", "update", "delete" - ] - } - ] - } - } -} diff --git a/src/Aspire.AppHost/AppHost.cs b/src/Aspire.AppHost/AppHost.cs index 5477c5c81b..3e4e3f597c 100644 --- a/src/Aspire.AppHost/AppHost.cs +++ b/src/Aspire.AppHost/AppHost.cs @@ -39,11 +39,11 @@ if (sqlDbContainer is null) { - mssqlService.WithEnvironment("ConnectionStrings__Database", databaseConnectionString); + mssqlService.WithEnvironment("DAB_CONNSTRING", databaseConnectionString); } else { - mssqlService.WithEnvironment("ConnectionStrings__Database", sqlDbContainer) + mssqlService.WithEnvironment("DAB_CONNSTRING", sqlDbContainer) .WaitFor(sqlDbContainer); } @@ -79,11 +79,11 @@ if (postgresDB is null) { - pgService.WithEnvironment("ConnectionStrings__Database", databaseConnectionString); + pgService.WithEnvironment("DAB_CONNSTRING", databaseConnectionString); } else { - pgService.WithEnvironment("ConnectionStrings__Database", postgresDB) + pgService.WithEnvironment("DAB_CONNSTRING", postgresDB) .WaitFor(postgresDB); } diff --git a/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs b/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs index 3a85ba823e..9394ee6f8a 100644 --- a/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs +++ b/src/Core/Services/MetadataProviders/SqlMetadataProvider.cs @@ -1478,7 +1478,7 @@ private async Task PopulateSourceDefinitionAsync( && IsGraphQLReservedName(entity, columnName, graphQLEnabledGlobally: runtimeConfig.IsGraphQLEnabled)) { throw new DataApiBuilderException( - message: $"The column '{columnName}' violates GraphQL name restrictions.", + message: $"The column '{columnName}' from {entityName} violates GraphQL name restrictions.", statusCode: HttpStatusCode.ServiceUnavailable, subStatusCode: DataApiBuilderException.SubStatusCodes.ErrorInInitialization); } diff --git a/src/Service/dab-config.json b/src/Service/dab-config.json index 859267100e..707fcb380f 100644 --- a/src/Service/dab-config.json +++ b/src/Service/dab-config.json @@ -1,231 +1,61 @@ { + "$schema": "https://github.com/Azure/data-api-builder/releases/latest/download/dab.draft.schema.json", "data-source": { - "database-type": "@env('db-type')", - "connection-string": "@env('ConnectionStrings__Database')", + "database-type": "mssql", + "connection-string": "@env('DAB_CONNSTRING')", "options": { "set-session-context": false } }, - "runtime": { - "rest": { - "enabled": true, - "path": "/api", - "request-body-strict": true - }, - "graphql": { - "enabled": true, - "path": "/graphql", - "allow-introspection": true - }, - "host": { - "authentication": { - "provider": "StaticWebApps" - }, - "cors": { - "origins": [], - "allow-credentials": false - }, - "mode": "development" - }, - "telemetry": { - "open-telemetry": { - "enabled": true, - "endpoint": "@env('OTEL_EXPORTER_OTLP_ENDPOINT')", - "headers": "@env('OTEL_EXPORTER_OTLP_HEADERS')", - "exporter-protocol": "@env('OTEL_EXPORTER_OTLP_PROTOCOL')", - "service-name": "@env('OTEL_SERVICE_NAME')" - } - }, - "cache": { - "enabled": true, - "ttl-seconds": 60 - } + "runtime": { + "rest": { + "enabled": true, + "path": "/api", + "request-body-strict": false }, - "entities": { - "Actor": { - "source": { - "object": "Actor", - "type": "table" - }, - "graphql": { - "enabled": true, - "type": { - "singular": "Actor", - "plural": "Actors" - } - }, - "rest": { - "enabled": true - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - "*" - ] - } - ], - "relationships": { - "character": { - "cardinality": "many", - "target.entity": "Character", - "source.fields": [ - "Id" - ], - "target.fields": [ - "ActorId" - ], - "linking.source.fields": [], - "linking.target.fields": [] - } - } + "graphql": { + "enabled": true, + "path": "/graphql", + "allow-introspection": true + }, + "mcp": { + "enabled": true, + "path": "/mcp" + }, + "host": { + "cors": { + "origins": ["*"], + "allow-credentials": false }, - "Character": { - "source": { - "object": "Character", - "type": "table" - }, - "graphql": { - "enabled": true, - "type": { - "singular": "Character", - "plural": "Characters" - } - }, - "rest": { - "enabled": true - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - } - ] - } - ], - "relationships": { - "actor": { - "cardinality": "one", - "target.entity": "Actor", - "source.fields": [ - "ActorId" - ], - "target.fields": [ - "Id" - ], - "linking.source.fields": [], - "linking.target.fields": [] - }, - "series": { - "cardinality": "many", - "target.entity": "Series", - "source.fields": [ - "Id" - ], - "target.fields": [ - "Id" - ], - "linking.object": "series_character", - "linking.source.fields": [ - "CharacterId" - ], - "linking.target.fields": [ - "SeriesId" - ] - } - } + "authentication": { + "provider": "Unauthenticated" + }, + "mode": "development" + } + }, + "autoentities": { + "default": { + "patterns": { + "include": ["%.%"], + "name": "{schema}_{object}" }, - "Series": { - "source": { - "object": "Series", - "type": "table" - }, - "graphql": { - "enabled": true, - "type": { - "singular": "Series", - "plural": "Series" - } - }, - "rest": { - "enabled": true - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - } - ] - } - ], - "relationships": { - "character": { - "cardinality": "many", - "target.entity": "Character", - "source.fields": [ - "Id" - ], - "target.fields": [ - "Id" - ], - "linking.object": "series_character", - "linking.source.fields": [ - "SeriesId" - ], - "linking.target.fields": [ - "CharacterId" - ] - } + "template": { + "mcp": { "dml-tools": true }, + "rest": { "enabled": true }, + "graphql": { "enabled": true }, + "health": { "enabled": true }, + "cache": { + "enabled": false } }, - "Species": { - "source": { - "object": "Species", - "type": "table" - }, - "graphql": { - "enabled": true, - "type": { - "singular": "Species", - "plural": "Species" - } - }, - "rest": { - "enabled": true - }, - "permissions": [ - { - "role": "anonymous", - "actions": [ - { - "action": "*" - } - ] - } - ], - "relationships": { - "character": { - "cardinality": "many", - "target.entity": "Character", - "source.fields": [ - "Id" - ], - "target.fields": [ - "Id" - ], - "linking.object": "character_species", - "linking.source.fields": [ - "SpeciesId" - ], - "linking.target.fields": [ - "CharacterId" - ] - } + "permissions": [ + { + "role": "anonymous", + "actions": [ + "*" + ] } - } + ] } } +}