Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Prepare Azure environments for new workloads—subscriptions, networking, identity, and landing zones
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/app-service/bicep.md
1# App Service Bicep Patterns23## Linux vs Windows45> ⚠️ **Warning:** `linuxFxVersion` and `reserved: true` are **Linux-only** properties. Setting `linuxFxVersion` on a Windows App Service Plan causes a deployment error: `LinuxFxVersion cannot be set for non-Linux App Service plans`. Omit both for Windows plans.67| Property | Linux | Windows |8|----------|-------|---------|9| Plan `reserved` | `true` | omit (defaults to `false`) |10| Site `kind` | `'app,linux'` | `'app'` |11| Site `linuxFxVersion` | e.g. `'NODE\|20-lts'` | omit |12| Site `WEBSITE_NODE_DEFAULT_VERSION` | omit | e.g. `'~20'` |1314> 💡 **Tip:** When both frontend and API use Node.js, prefer a **single Linux App Service Plan** for both. This avoids mixed-platform complexity and keeps all services on one plan.1516## Linux App Service (Recommended for Node.js)1718> ⚠️ **REQUIRED: `azd-service-name` tag** — The `tags` property MUST include `union(tags, { 'azd-service-name': serviceName })` so that `azd deploy` can locate the resource. Without this tag, `azd deploy` fails with `resource not found: unable to find a resource tagged with 'azd-service-name: web'`.1920```bicep21resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {22name: '${resourcePrefix}-plan-${uniqueHash}'23location: location24kind: 'linux'25sku: {26name: 'B1'27tier: 'Basic'28}29properties: {30reserved: true // Required for Linux31}32}3334resource webApp 'Microsoft.Web/sites@2022-09-01' = {35name: '${resourcePrefix}-${serviceName}-${uniqueHash}'36location: location37kind: 'app,linux'38tags: union(tags, { 'azd-service-name': serviceName }) // REQUIRED for azd deploy39properties: {40serverFarmId: appServicePlan.id41siteConfig: {42linuxFxVersion: 'NODE|20-lts'43alwaysOn: true44healthCheckPath: '/health'45appSettings: [46{47name: 'SCM_DO_BUILD_DURING_DEPLOYMENT'48value: 'true' // Required for source-based Node.js deploys (azd deploy)49}50{51name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'52value: applicationInsights.properties.ConnectionString53}54{55name: 'ApplicationInsightsAgent_EXTENSION_VERSION'56value: '~3'57}58]59}60httpsOnly: true61}62identity: {63type: 'SystemAssigned'64}65}66```6768## Windows App Service6970Use when the runtime requires Windows (e.g. .NET Framework) or when explicitly requested.7172```bicep73resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {74name: '${resourcePrefix}-plan-${uniqueHash}'75location: location76sku: {77name: 'B1'78tier: 'Basic'79}80// Do NOT set reserved: true for Windows81}8283resource webApp 'Microsoft.Web/sites@2022-09-01' = {84name: '${resourcePrefix}-${serviceName}-${uniqueHash}'85location: location86kind: 'app'87tags: union(tags, { 'azd-service-name': serviceName }) // REQUIRED for azd deploy88properties: {89serverFarmId: appServicePlan.id90siteConfig: {91// Do NOT set linuxFxVersion for Windows plans92alwaysOn: true93healthCheckPath: '/health'94appSettings: [95{96name: 'SCM_DO_BUILD_DURING_DEPLOYMENT'97value: 'true' // Required for source-based Node.js deploys (azd deploy)98}99{100name: 'WEBSITE_NODE_DEFAULT_VERSION'101value: '~20'102}103{104name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'105value: applicationInsights.properties.ConnectionString106}107{108name: 'ApplicationInsightsAgent_EXTENSION_VERSION'109value: '~3'110}111]112}113httpsOnly: true114}115identity: {116type: 'SystemAssigned'117}118}119```120121## Node.js Build Configuration122123> ⚠️ **Warning:** For source-based Node.js deployments to App Service (e.g. `azd deploy`), you **must** set `SCM_DO_BUILD_DURING_DEPLOYMENT=true` so App Service runs `npm install` during deployment. Without this, the app fails at runtime with `Cannot find module` errors.124125This setting is already included in both the Linux and Windows examples above.126127## Key Vault Integration128129Reference secrets from Key Vault:130131```bicep132appSettings: [133{134name: 'DATABASE_URL'135value: '@Microsoft.KeyVault(VaultName=${keyVault.name};SecretName=database-url)'136}137]138```139