microsoft/aspire · error · ArgumentException
configure or configureSlot must be provided.
Error message
configure or configureSlot must be provided.
What it means
PublishAsAzureAppServiceWebsite accepts two optional callbacks: one for the base website configuration and one for slot-specific configuration. If both are null there is nothing to configure, so the extension throws an ArgumentException rather than silently doing nothing.
Solutions
- Pass a configure lambda: b => { ... } describing the website settings you want.
- Pass configureSlot instead if you only need per-slot customization.
- Remove the PublishAsAzureAppServiceWebsite call entirely if no customization is needed.
- If configure is conditionally built, fall back to an empty lambda b => { } instead of null.
Example fix
// before
builder.PublishAsAzureAppServiceWebsite(null, null);
// after
builder.PublishAsAzureAppServiceWebsite(website => { website.Template.SetProperty("siteConfig", new { http20Enabled = true }); }); Defensive patterns
Strategy: validation
Validate before calling
if (configure is null && configureSlot is null) throw new ArgumentException("Provide configure or configureSlot before calling PublishAsAzureAppServiceWebsite."); Try / catch
try { builder.PublishAsAzureAppServiceWebsite(configure, configureSlot); } catch (ArgumentException ex) { logger.LogError(ex, "PublishAsAzureAppServiceWebsite requires at least one callback"); } Prevention
- Never pass null for both callbacks; use an empty lambda when no customization is needed.
- Wrap the extension in a helper that enforces a non-null callback.
- Review fluent chains after refactors that remove lambda bodies.
When it happens
Trigger: Calling builder.PublishAsAzureAppServiceWebsite() with no arguments at all, or explicitly passing null for both configure and configureSlot, on an IComputeResource.
Common situations: Copy-pasting the call from docs and omitting the lambda; generating the call from a templating tool that leaves the configure argument unfilled; refactoring that removed the lambda body but kept a null argument.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- App Service configuration validation failed. See errors…
- App Service context not found for resource
- App Service plan id ' ' does not contain a resource group…
- Application Insights must be omitted, a location string, a…
- Deployment slot must be a string or a parameter resource…
AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16).
Data as JSON: /api/errors/b602a6782a664a1c.
Report an issue: GitHub.
Appendix: source
Thrown at src/Aspire.Hosting.Azure.AppService/AzureAppServiceComputeResourceExtensions.cs:44
/// builder.AddProject<Projects.Api>("name").PublishAsAzureAppServiceWebsite((infrastructure, app) =>
/// {
/// // Configure the App Service WebSite resource here
/// });
/// </code>
/// </example>
/// </remarks>
/// <ats-remarks />
[AspireExport]
public static IResourceBuilder<T> PublishAsAzureAppServiceWebsite<T>(this IResourceBuilder<T> builder,
Action<AzureResourceInfrastructure, WebSite>? configure = null,
Action<AzureResourceInfrastructure, WebSiteSlot>? configureSlot = null)
where T : IComputeResource
{
ArgumentNullException.ThrowIfNull(builder);
if (configure == null && configureSlot == null)
{
throw new ArgumentException("configure or configureSlot must be provided.");
}
if (!builder.ApplicationBuilder.ExecutionContext.IsPublishMode)
{
return builder;
}
builder.ApplicationBuilder.AddAzureAppServiceInfrastructureCore();
if (configure != null)
{
builder = builder.WithAnnotation(new AzureAppServiceWebsiteCustomizationAnnotation(configure));
}
if (configureSlot != null)
{
builder = builder.WithAnnotation(new AzureAppServiceWebsiteSlotCustomizationAnnotation(configureSlot));
}View on GitHub (pinned to 25830f84bd)