{"record":{"id":"b602a6782a664a1c","repo":"microsoft/aspire","slug":"configure-or-configureslot-must-be-provided","errorCode":null,"errorMessage":"configure or configureSlot must be provided.","messagePattern":"configure or configureSlot must be provided\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.Azure.AppService/AzureAppServiceComputeResourceExtensions.cs","lineNumber":44,"sourceCode":"    /// builder.AddProject&lt;Projects.Api&gt;(\"name\").PublishAsAzureAppServiceWebsite((infrastructure, app) =>\n    /// {\n    ///     // Configure the App Service WebSite resource here\n    /// });\n    /// </code>\n    /// </example>\n    /// </remarks>\n    /// <ats-remarks />\n    [AspireExport]\n    public static IResourceBuilder<T> PublishAsAzureAppServiceWebsite<T>(this IResourceBuilder<T> builder,\n        Action<AzureResourceInfrastructure, WebSite>? configure = null,\n        Action<AzureResourceInfrastructure, WebSiteSlot>? configureSlot = null)\n        where T : IComputeResource\n    {\n        ArgumentNullException.ThrowIfNull(builder);\n\n        if (configure == null && configureSlot == null)\n        {\n            throw new ArgumentException(\"configure or configureSlot must be provided.\");\n        }\n\n        if (!builder.ApplicationBuilder.ExecutionContext.IsPublishMode)\n        {\n            return builder;\n        }\n\n        builder.ApplicationBuilder.AddAzureAppServiceInfrastructureCore();\n\n        if (configure != null)\n        {\n            builder = builder.WithAnnotation(new AzureAppServiceWebsiteCustomizationAnnotation(configure));\n        }\n\n        if (configureSlot != null)\n        {\n            builder = builder.WithAnnotation(new AzureAppServiceWebsiteSlotCustomizationAnnotation(configureSlot));\n        }","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.Azure.AppService/AzureAppServiceComputeResourceExtensions.cs#L26-L62","documentation":"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.","triggerScenarios":"Calling builder.PublishAsAzureAppServiceWebsite() with no arguments at all, or explicitly passing null for both configure and configureSlot, on an IComputeResource.","commonSituations":"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.","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."],"exampleFix":"// before\nbuilder.PublishAsAzureAppServiceWebsite(null, null);\n// after\nbuilder.PublishAsAzureAppServiceWebsite(website => { website.Template.SetProperty(\"siteConfig\", new { http20Enabled = true }); });","handlingStrategy":"validation","validationCode":"if (configure is null && configureSlot is null) throw new ArgumentException(\"Provide configure or configureSlot before calling PublishAsAzureAppServiceWebsite.\");","typeGuard":null,"tryCatchPattern":"try { builder.PublishAsAzureAppServiceWebsite(configure, configureSlot); } catch (ArgumentException ex) { logger.LogError(ex, \"PublishAsAzureAppServiceWebsite requires at least one callback\"); }","preventionTips":["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."],"tags":["azure","appservice","arguments"],"backgroundTag":"missing-required-argument","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}