
Often you don’t need all the configurations of an app per stage; sometimes they are optional. This is often the case for the development stage in particular.
Bicep supports conditions by default, but in many examples they are not really well described or even readable. Here is a snippet of how I usually do it:
1// sample param, empty string as fallback
2param corsOption string = ''
3
4// required web app settings
5var requiredWebAppSettings = [
6 {
7 name: 'CosmosDB__Endpoint'
8 value: cosmosAccount.outputs.endpoint
9 }
10 {
11 name: 'CosmosDB__Database'
12 value: db.outputs.name
13 }
14]
15
16// optional entry for cors
17
18var optionalWebAppCorsConfig = corsOption != '' ? [
19 {
20 name: 'CorsOptions__Origins'
21 value: corsOption
22 }
23] : []
24
25
26// create web app config
27module backendApp './modules/app-service-webapp-linux.bicep' = {
28 name: 'deploy-${backendAppName}'
29 params: {
30 name: backendAppName
31 location: location
32 environmentVariables: concat(appApiEnvVarsCollection, appApiCorsOptionsOriginsSection)
33 }
34}
Thanks to concat we have an array with mandatory variables that must always be set and an array with optional cors settings that are only set if the corsOption parameter is not empty. This is now very easy to control, for example with variables in Azure DevOps.
Related articles

Feb 26, 2026 · 6 min read
Run Azure Cosmos DB locally with .NET Aspire and make emulator endpoints visible in the dashboard
When building cloud-native .NET applications, two goals often matter at the same time: a fast local development loop and a clean path to …

Sep 24, 2025 · 9 min read
Automatically discover tools for Azure OpenAI Realtime API
Azure now provides a unified Realtime API for low‑latency, multimodal conversations over WebRTC or WebSockets. If you’ve used the earlier …

Sep 01, 2025 · 3 min read
Azure Document Intelligence – Fix: ContentSourceNotAccessible (Invalid data URL)
Problem Training custom models (for example, delivery notes) in Azure Document Intelligence initially worked fine. Suddenly, both training …
Let's Work Together
Looking for an experienced Platform Architect or Engineer for your next project? Whether it's cloud migration, platform modernization or building new solutions from scratch - I'm here to help you succeed.

Comments