Skip to content

Commit e7def71

Browse files
adamintCopilot
andcommitted
Configure custom domain via Aspire ConfigureCustomDomain API
The custom domain (learnaspire.dev) is now declared in the AppHost using ConfigureCustomDomain, so it's included in the generated Bicep and survives deployments. Replaces the fragile post-deploy re-bind. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d4c0c68 commit e7def71

2 files changed

Lines changed: 16 additions & 6 deletions

File tree

.github/workflows/release.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,8 @@ jobs:
270270
Azure__Location: ${{ env.AZURE_LOCATION }}
271271
ConnectionStrings__openai: ${{ secrets.OPENAI_CONNECTION_STRING }}
272272
Parameters__jwt-key: ${{ secrets.JWT_KEY }}
273+
Parameters__customDomain: learnaspire.dev
274+
Parameters__certificateName: ${{ secrets.ACA_CERT_NAME }}
273275
run: aspire deploy --non-interactive --clear-cache
274276
timeout-minutes: 20
275277

@@ -288,17 +290,17 @@ jobs:
288290
- name: Smoke test
289291
if: steps.url.outputs.url != ''
290292
run: |
291-
echo "Running smoke test against ${{ steps.url.outputs.url }}..."
293+
echo "Running smoke test against https://learnaspire.dev..."
292294
for i in {1..5}; do
293-
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${{ steps.url.outputs.url }}/health" --max-time 15 || echo "000")
295+
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://learnaspire.dev/health" --max-time 15 || echo "000")
294296
if [[ "$STATUS" == "200" ]]; then
295-
echo "✓ Health check passed (attempt $i)"
297+
echo "✓ Health check passed on learnaspire.dev (attempt $i)"
296298
exit 0
297299
fi
298300
echo " Attempt $i: got $STATUS, retrying in 15s..."
299301
sleep 15
300302
done
301-
echo "::warning::Smoke test did not get 200 from /health after 5 attempts"
303+
echo "::warning::Smoke test did not get 200 from learnaspire.dev/health after 5 attempts"
302304
303305
- name: Update GitHub Release with deploy info
304306
if: startsWith(github.ref, 'refs/tags/v') && steps.url.outputs.url != ''

apphost.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#:package Aspire.Hosting.Azure.PostgreSQL@13.*
33
#:package Aspire.Hosting.Azure.AppContainers@13.*
44
#:package Aspire.Hosting.JavaScript@13.*
5-
#:property NoWarn=ASPIRECSHARPAPPS001
5+
#:property NoWarn=ASPIRECSHARPAPPS001;ASPIREACADOMAINS001
66

77
#pragma warning disable ASPIREPUBLISHERS001 // Azure publishers are in preview
88

@@ -19,13 +19,21 @@
1919
var postgres = postgresServer.AddDatabase("academydb");
2020
var openai = builder.AddConnectionString("openai");
2121

22+
// Custom domain parameters (used only during publish/deploy)
23+
var customDomain = builder.AddParameter("customDomain");
24+
var certificateName = builder.AddParameter("certificateName");
25+
2226
// API backend
2327
var api = builder.AddCSharpApp("api", "./AspireAcademy.Api/")
2428
.WithReference(postgres)
2529
.WithReference(openai)
2630
.WaitFor(postgres)
2731
.WithHttpHealthCheck("/health")
28-
.WithExternalHttpEndpoints();
32+
.WithExternalHttpEndpoints()
33+
.PublishAsAzureContainerApp((infra, app) =>
34+
{
35+
app.ConfigureCustomDomain(customDomain, certificateName);
36+
});
2937

3038
if (builder.ExecutionContext.IsRunMode)
3139
{

0 commit comments

Comments
 (0)