1

I am trying to create multiple function apps with different plans (e.g., Consumption, Flex Consumption). I have created an array that passes the values to the app service plan and the function app. The problem I am facing is that while making the resources, the bicep is not able to map the appropriate app service plan. I have tried the one-to-one indexing it is not working. Is there any other way we can refer to the app service plans resource ID in the function app?

I have bifurcated the function app module further so that it can be created as per the parameters passed for different plans.

I am using the Azure Verified Module to develop the resources

=============main.bicep=============== module appServicePlan './Modules/AppServicePlan/appServicePlan.bicep' = [ for fa in functionApps.appServicePlans: { name: 'appserviceplan-${fa.key}' a params: { name: '${fa.key}-asp' kind: fa.kind location: location skuName: fa.skuName skuCapacity: fa.skuCapacity zoneRedundant: fa.zoneRedundant elasticScaleEnabled: fa.elasticScaleEnabled perSiteScaling: fa.perSiteScaling targetWorkerCount: fa.targetWorkerCount targetWorkerSize: fa.targetWorkerSize maximumElasticWorkerCount: fa.maximumElasticWorkerCount reserved: fa.reserved diagnosticSettings: fa.diagnosticSettings aspPlan: fa.aspPlan } } ] module functionAppModule './Modules/FunctionApp/functionApp.bicep' = [ for (fa, i) in functionApps.functionApps: { name: 'funappsdeploye-${fa.key}-${uniqueString(resourceGroup().id, fa.key)}' params: { name: '${fa.key}' deploymentName: 'functionapps-${fa.key}-${uniqueString(resourceGroup().id, fa.key)}' kind: fa.kind functionAppType: fa.functionAppType serverFarmResourceId: // configs: [ // { // // applicationInsightResourceId : // name : fa.configs[i].name // properties : fa.configs[i].properties // // storageAccountResourceId // storageAccountUseIdentityAuthentication : fa.configs[i].storageAccountUseIdentityAuthentication // } // ] outboundVnetRouting : fa.outboundVnetRouting diagnosticSettings: fa.diagnosticSettings publicNetworkAccess: fa.publicNetworkAccess location: location managedIdentities: fa.managedIdentities siteConfig: fa.siteConfig // virtualNetworkSubnetResourceId: fa.subnetDelegation == 'Microsoft.App/serverFarms' // ? functionAppsServerFarmsSubnetId // : functionAppEnvironmentsSubnetId // privateEndpoints: empty(privateEndpointSubnetId) // ? [] // : [ // { // name: '${namingModule.outputs.names.functionApp.name}-${fa.key}-pe' // service: 'sites' // subnetResourceId: privateEndpointSubnetId // privateDnsZoneGroup: { // privateDnsZoneGroupConfigs: [ // { // privateDnsZoneResourceId: resourceId( // resourceGroup().name, // 'Microsoft.Network/privateDnsZones', // 'privatelink.azurewebsites.net' // ) // } // ] // } // } // ] functionAppConfig: { deployment: { storage: { type: 'blobcontainer' value: 'https://${storageAccount.outputs.name}.blob.core.windows.net/${fa.fnappStorageAccount.storageBlobContainerName}' authentication: { type: 'systemassignedidentity' } } } scaleAndConcurrency: { maximumInstanceCount: 100 instanceMemoryMB: 2048 } runtime: { name: 'dotnet-isolated' version: '8.0' } } tags: tags } dependsOn: [ appServicePlan ] } ] 
==============parameter.json=============== { "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", "contentVersion": "1.0.0.0", "parameters": { "functionApps": { "value": { "appServicePlans": [ { "key": "admindashboard2", "kind": "functionapp", "skuName": "Y1", "skuCapacity": 0, "zoneRedundant": false, "elasticScaleEnabled": false, "perSiteScaling": false, "targetWorkerCount": 0, "targetWorkerSize": 0, "maximumElasticWorkerCount": 0, "reserved": true, "diagnosticSettings": [], "aspPlan": "Consumption" }, { "key": "admindashboard1", "kind": "functionapp", "skuName": "FC1", "skuCapacity": 0, "zoneRedundant": false, "elasticScaleEnabled": false, "perSiteScaling": false, "targetWorkerCount": 0, "targetWorkerSize": 0, "maximumElasticWorkerCount": 0, "reserved": true, "diagnosticSettings": [], "aspPlan": "FlexConsumption" } ], "functionApps": [ { "key": "admindashboard01", "kind": "functionapp,linux", "subnetDelegation": "Microsoft.App/environments", "functionAppType": "FlexConsumption", "location": "eastus", "httpsOnly": true, "fnappStorageAccount": { "storageAccountIndex": 0, "storageBlobContainerName": "admindashboard" }, "configs": [ { "name": "appsettings", "properties": { "APPLICATIONINSIGHTS_AUTHENTICATION_STRING": "Authorization=AAD", "AzureWebJobsServiceBus": "", "AzureFunctionsWebHost__hostid": "admindashboard-dev", "kvEnv": "", "AzureWebJobsStorage__accountName": "" }, "storageAccountUseIdentityAuthentication": true } ], "diagnosticSettings": [], "publicNetworkAccess": "Enabled", "managedIdentities": { "systemAssigned": true }, "outboundVnetRouting": { "allTraffic": true, "contentShareTraffic": true, "imagePullTraffic": true }, "siteConfig": { "healthCheckPath": "/", "use32BitWorkerProcess": false, "http20Enabled": true, "minTlsVersion": "1.2", "scmSiteConfig": { "useScmSecurity": false, "ftpsState": "Disabled" }, "ipSecurityRestrictionsDefaultAction": "Allow", "ipSecurityRestrictions": [], "scmIpSecurityRestrictionsDefaultAction": "Allow", "scmIpSecurityRestrictionsUseMain": true, "scmIpSecurityRestrictions": [ { "ipAddress": "any", "action": "deny", "priority": 2147483647, "name": "Deny all", "description": "Deny all access" } ] } }, { "key": "admindashboard02", "kind": "functionapp,linux", "subnetDelegation": "Microsoft.App/environments", "functionAppType": "Consumption", "location": "eastus", "httpsOnly": true, "fnappStorageAccount": { "storageAccountIndex": 0, "storageBlobContainerName": "admindashboard" }, "configs": [ { "name": "appsettings", "properties": { "APPLICATIONINSIGHTS_AUTHENTICATION_STRING": "Authorization=AAD", "AzureWebJobsServiceBus": "", "AzureFunctionsWebHost__hostid": "admindashboard-dev", "kvEnv": "", "AzureWebJobsStorage__accountName": "" }, "storageAccountUseIdentityAuthentication": true } ], "diagnosticSettings": [], "publicNetworkAccess": "Enabled", "managedIdentities": { "systemAssigned": true }, "outboundVnetRouting": { "allTraffic": true, "contentShareTraffic": true, "imagePullTraffic": true }, "siteConfig": { "healthCheckPath": "/", "use32BitWorkerProcess": false, "http20Enabled": true, "minTlsVersion": "1.2", "scmSiteConfig": { "useScmSecurity": false, "ftpsState": "Disabled" }, "ipSecurityRestrictionsDefaultAction": "Allow", "ipSecurityRestrictions": [], "scmIpSecurityRestrictionsDefaultAction": "Allow", "scmIpSecurityRestrictionsUseMain": true, "scmIpSecurityRestrictions": [ { "ipAddress": "any", "action": "deny", "priority": 2147483647, "name": "Deny all", "description": "Deny all access" } ] } } ] } } } } 
2
  • Hi, would you be able to paste the rror you are getting ? Commented Nov 14 at 7:58
  • also can you share the details of the modules you re referencing ? Commented Nov 17 at 6:56

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.