Implementing co-hosting of the API in the Web container for Production — Azure only deploys Web, but Production HttpClients still target Aspire's api hostname.
[tool: run_terminal_command_v2 — Tool use: run_terminal_command_v2 • Run command: cd /Users/[user]/Projects/Private/dotnet/SchaerbeekMunicipality && dotnet build 2>&1 | tail -20]
[tool: run_terminal_command_v2 — Tool use: run_terminal_command_v2 • Run command: cd /Users/[user]/Projects/Private/dotnet/SchaerbeekMunicipality && dotnet test tests/SchaerbeekMunicipality.Integration.Tests --no-build 2>&am]
[tool: run_terminal_command_v2 — Tool use: run_terminal_command_v2 • Run command: cd /Users/[user]/Projects/Private/dotnet/SchaerbeekMunicipality && ASPNETCORE_ENVIRONMENT=Production dotnet run --project src/SchaerbeekMunicipal]
[tool: run_terminal_command_v2 — Tool use: run_terminal_command_v2 • Run command: cd /Users/[user]/Projects/Private/dotnet/SchaerbeekMunicipality/src/SchaerbeekMunicipality.Web/bin/Debug/net10.0 && ASPNETCORE_ENVIRONMENT=Produc]
Root cause
The error is a DNS failure when the Web app tries to call the backend API. The stack trace shows ResolvingHttpDelegatingHandler, which is .NET Aspire service discovery.
Your Azure deployment runs only the Web container (schaerbeek-web), but in Production the HTTP clients were configured like this:
// (before fix)
?? new Uri(environment.IsDevelopment() ? "http://api" : "https+http://api");
Locally, Aspire resolves the hostname api to the separate API project. On Azure there is no Aspire orchestrator and no api service — so DNS lookup fails with "Name or service not known".
That call is triggered as soon as the UI loads — MainLayout.razor fetches pending police verifications for the nav badge.
Fix applied
I've updated the app so Production co-hosts the API inside the same Web process (matching the single-container Azure model):
MunicipalApiHostExtensions — shared API bootstrap (DB, endpoints, middleware)
Web/Program.cs — registers and maps the API when ASPNETCORE_ENVIRONMENT=Production
DependencyInjection.cs — Production HttpClients now loop back to http://127.0.0.1:8080 instead of https+http://api
Verified locally in Production mode: /health → 200, /api/registration/police-verifications/pending → 200.
Redeploy
You need a new container image with this fix, then redeploy:
bash
# After pushing the code and waiting for GHCR publish (or build locally)
cd deploy/azure/sqlite
# Update parameters.json containerImage to the new SHA tag
./deploy.sh
Or trigger your GitHub Container publish workflow, then update containerImage in parameters.json to the new tag.
After redeploy, the app at https://schaerbeek-web.gentledesert-b97640b1.westeurope.azurecontainerapps.io should load without the DNS errors. The first request after scale-to-zero may still take 15–45 seconds (cold start + SQLite init + seeding), which is expected.
Want me to commit these changes or help with the redeploy steps?
When I commit and the build launch I had the following error:
#14 [build 7/7] RUN dotnet publish src/SchaerbeekMunicipality.Web/SchaerbeekMunicipality.Web.csproj -c Release -o /app/publish /p:UseAppHost=false
#14 1.465 Determining projects to restore...
#14 3.063 Restored /src/src/SchaerbeekMunicipality.Domain/SchaerbeekMunicipality.Domain.csproj (in 125 ms).
#14 4.874 Restored /src/src/SchaerbeekMunicipality.ServiceDefaults/SchaerbeekMunicipality.ServiceDefaults.csproj (in 1.8 sec).
#14 5.057 Restored /src/src/SchaerbeekMunicipality.Application/SchaerbeekMunicipality.Application.csproj (in 2.14 sec).
#14 5.060 Restored /src/src/SchaerbeekMunicipality.Api/SchaerbeekMunicipality.Api.csproj (in 2.13 sec).
#14 5.063 Restored /src/src/SchaerbeekMunicipality.Web/SchaerbeekMunicipality.Web.csproj (in 2.14 sec).
#14 5.742 Restored /src/src/SchaerbeekMunicipality.Infrastructure/SchaerbeekMunicipality.Infrastructure.csproj (in 857 ms).
#14 10.59 SchaerbeekMunicipality.ServiceDefaults -> /src/src/SchaerbeekMunicipality.ServiceDefaults/bin/Release/net10.0/SchaerbeekMunicipality.ServiceDefaults.dll
#14 10.60 SchaerbeekMunicipality.Domain -> /src/src/SchaerbeekMunicipality.Domain/bin/Release/net10.0/SchaerbeekMunicipality.Domain.dll
#14 13.41 SchaerbeekMunicipality.Infrastructure -> /src/src/SchaerbeekMunicipality.Infrastructure/bin/Release/net10.0/SchaerbeekMunicipality.Infrastructure.dll
#14 15.79 SchaerbeekMunicipality.Application -> /src/src/SchaerbeekMunicipality.Application/bin/Release/net10.0/SchaerbeekMunicipality.Application.dll
#14 17.99 SchaerbeekMunicipality.Api -> /src/src/SchaerbeekMunicipality.Api/bin/Release/net10.0/SchaerbeekMunicipality.Api.dll
#14 26.36 SchaerbeekMunicipality.Web -> /src/src/SchaerbeekMunicipality.Web/bin/Release/net10.0/SchaerbeekMunicipality.Web.dll
#14 28.19 /usr/share/dotnet/sdk/10.0.301/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path: /src/src/SchaerbeekMunicipality.Api/appsettings.Development.json, /src/src/SchaerbeekMunicipality.Web/appsettings.Development.json, /src/src/SchaerbeekMunicipality.Api/appsettings.json, /src/src/SchaerbeekMunicipality.Web/appsettings.json. [/src/src/SchaerbeekMunicipality.Web/SchaerbeekMunicipality.Web.csproj]
#14 ERROR: process "/bin/sh -c dotnet publish src/SchaerbeekMunicipality.Web/SchaerbeekMunicipality.Web.csproj -c Release -o /app/publish /p:UseAppHost=false" did not complete successfully: exit code: 1
[build 7/7] RUN dotnet publish src/SchaerbeekMunicipality.Web/SchaerbeekMunicipality.Web.csproj -c Release -o /app/publish /p:UseAppHost=false:
5.060 Restored /src/src/SchaerbeekMunicipality.Api/SchaerbeekMunicipality.Api.csproj (in 2.13 sec).
5.063 Restored /src/src/SchaerbeekMunicipality.Web/SchaerbeekMunicipality.Web.csproj (in 2.14 sec).
5.742 Restored /src/src/SchaerbeekMunicipality.Infrastructure/SchaerbeekMunicipality.Infrastructure.csproj (in 857 ms).
10.59 SchaerbeekMunicipality.ServiceDefaults -> /src/src/SchaerbeekMunicipality.ServiceDefaults/bin/Release/net10.0/SchaerbeekMunicipality.ServiceDefaults.dll
10.60 SchaerbeekMunicipality.Domain -> /src/src/SchaerbeekMunicipality.Domain/bin/Release/net10.0/SchaerbeekMunicipality.Domain.dll
13.41 SchaerbeekMunicipality.Infrastructure -> /src/src/SchaerbeekMunicipality.Infrastructure/bin/Release/net10.0/SchaerbeekMunicipality.Infrastructure.dll
15.79 SchaerbeekMunicipality.Application -> /src/src/SchaerbeekMunicipality.Application/bin/Release/net10.0/SchaerbeekMunicipality.Application.dll
17.99 SchaerbeekMunicipality.Api -> /src/src/SchaerbeekMunicipality.Api/bin/Release/net10.0/SchaerbeekMunicipality.Api.dll
26.36 SchaerbeekMunicipality.Web -> /src/src/SchaerbeekMunicipality.Web/bin/Release/net10.0/SchaerbeekMunicipality.Web.dll
28.19 /usr/share/dotnet/sdk/10.0.301/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.ConflictResolution.targets(112,5): error NETSDK1152: Found multiple publish output files with the same relative path: /src/src/SchaerbeekMunicipality.Api/appsettings.Development.json, /src/src/SchaerbeekMunicipality.Web/appsettings.Development.json, /src/src/SchaerbeekMunicipality.Api/appsettings.json, /src/src/SchaerbeekMunicipality.Web/appsettings.json. [/src/src/SchaerbeekMunicipality.Web/SchaerbeekMunicipality.Web.csproj]
Fixing the publish conflict: Web references Api (both Sdk.Web), so their appsettings.*.json files collide during Docker publish.
[tool: run_terminal_command_v2 — Tool use: run_terminal_command_v2 • Run command: cd /Users/[user]/Projects/Private/dotnet/SchaerbeekMunicipality && rm -rf /tmp/schaerbeek-web-publish && dotnet publish src/SchaerbeekMun]
The Docker build failed because Web now references Api, and both are Sdk.Web projects — each ships its own appsettings.json and appsettings.Development.json. During dotnet publish, those files map to the same output paths, which triggers NETSDK1152.
Fix
In SchaerbeekMunicipality.Api.csproj, Api's appsettings are excluded from the publish output. That's correct for the container image: Web owns configuration there (including appsettings.Production.json with the SQLite connection string).
Local dotnet publish for Web now succeeds, and the output contains only Web's appsettings (appsettings.json, appsettings.Development.json, appsettings.Production.json).
Commit and push this change — the GHCR build should pass. Local Aspire dev is unaffected; Api still uses its own appsettings when run directly via AppHost.