Skip to content

Instantly share code, notes, and snippets.

@MudraR
Created December 6, 2024 13:56
Show Gist options
  • Select an option

  • Save MudraR/2848e586e5853eb1585fa4c60a8fceeb to your computer and use it in GitHub Desktop.

Select an option

Save MudraR/2848e586e5853eb1585fa4c60a8fceeb to your computer and use it in GitHub Desktop.
[Bicep] Create App Services Using For Loop
# Quick Working POC using for loops in bicep to create an App Service Plan and AppServices from an array.
# https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/loops
@description('The Azure region into which the resources should be deployed.')
param location string = 'southcentralus'
@description('app services to provision')
param appServiceAppNames array = [
'App1'
'App2'
'App3'
'App4'
'App5'
'App6'
]
resource appServicePlan 'Microsoft.Web/serverfarms@2024-04-01' = {
name: 'AppServicePlanName'
location: location
sku: {
name: 'S1'
tier: 'Standard'
}
}
resource appServiceApp 'Microsoft.Web/sites@2024-04-01' = [for appServiceAppName in appServiceAppNames: {
name: appServiceAppName
location: location
properties: {
serverFarmId: appServicePlan.id
httpsOnly: true
}
}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment