Skip to content

Deployment Parameters

AvantiPoint.Aspire.Hosting.Extensions provides AddDeploymentParameter, a small, provider-agnostic helper for configuration that should be required when you deploy but absent during local development — things like a hostname, a Zone ID, a production connection string, or a token you only need against the real cloud.

A normal builder.AddParameter("x") prompts (or fails) when the value is missing, which gets in the way of a credential-free aspire run. AddDeploymentParameter resolves to a real Aspire parameter during aspire publish/aspire deploy, but to an empty, non-prompting parameter during aspire run.

var builder = DistributedApplication.CreateBuilder(args);
// Required at deploy, optional in dev.
var zone = builder.AddDeploymentParameter("zone-id");
var apiHost = builder.AddDeploymentParameter("api-hostname");
var dbConn = builder.AddDeploymentParameter("pg-production-connection", secret: true);

These can be passed anywhere a parameter is accepted — for example a Cloudflare custom domain or a Hyperdrive production connection string:

api.WithCustomDomain(apiHost, zone);
builder.AddPostgres("pg").PublishAsHyperdrive("hd", dbConn);
Mode Behavior
aspire run Resolves to an empty parameter — no prompt, no failure, so the inner loop stays credential-free.
aspire publish / aspire deploy Resolves to a real Aspire parameter, sourced from environment variables / user-secrets / configuration like any other.

Pass secret: true for sensitive values. The overload taking a ParameterDefault is C#-only; it has no TypeScript export. TypeScript uses the exported no-default overload shown above.

The PostgreSQL example requires Aspire.Hosting.PostgreSQL in the C# AppHost or in the TypeScript aspire.config.json packages at version 13.6.0.