@@ -2,10 +2,7 @@ param name string
22param location string = resourceGroup ().location
33param tags object = {}
44param applicationInsightsName string = ''
5- param appServicePlanId string
65param appSettings object = {}
7- param runtimeName string
8- param runtimeVersion string
96param serviceName string = 'api'
107param storageAccountName string
118param deploymentStorageContainerName string
@@ -15,34 +12,96 @@ param maximumInstanceCount int = 100
1512param identityId string = ''
1613param identityClientId string = ''
1714param aiServicesId string
15+ param resourceToken string
16+
17+ param runtimeName string = 'python'
18+ param runtimeVersion string = '3.11'
19+
20+ @allowed (['SystemAssigned' , 'UserAssigned' ])
21+ param identityType string = 'UserAssigned'
22+
23+ import * as regionSelector from './util/region-selector.bicep'
24+ var abbrs = loadJsonContent ('../abbreviations.json' )
1825
1926var applicationInsightsIdentity = 'ClientId=${identityClientId };Authorization=AAD'
2027
21- module api '../core/host/functions-flexconsumption.bicep' = {
28+ // The application backend is a function app
29+ module appServicePlan 'br/public:avm/res/web/serverfarm:0.1.1' = {
30+ name : 'appserviceplan'
31+ params : {
32+ name : '${abbrs .webServerFarms }${resourceToken }'
33+ location : regionSelector .getFlexConsumptionRegion (location )
34+ tags : tags
35+ sku : {
36+ name : 'FC1'
37+ tier : 'FlexConsumption'
38+ }
39+ reserved : true
40+ }
41+ }
42+
43+ resource stg 'Microsoft.Storage/storageAccounts@2022-09-01' existing = {
44+ name : storageAccountName
45+ }
46+
47+ resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = if (!empty (applicationInsightsName )) {
48+ name : applicationInsightsName
49+ }
50+
51+ module api 'br/public:avm/res/web/site:0.15.1' = {
2252 name : '${serviceName }-functions-module'
2353 params : {
2454 name : name
2555 location : location
56+ kind : 'functionapp,linux'
2657 tags : union (tags , { 'azd-service-name' : serviceName })
27- identityType : 'UserAssigned'
28- identityId : identityId
29- appSettings : union (appSettings ,
58+ managedIdentities : {
59+ systemAssigned : identityType == 'SystemAssigned'
60+ userAssignedResourceIds : [
61+ '${identityId }'
62+ ]
63+ }
64+ serverFarmResourceId : appServicePlan .outputs .resourceId
65+ functionAppConfig : {
66+ location : location
67+ deployment : {
68+ storage : {
69+ type : 'blobContainer'
70+ value : '${stg .properties .primaryEndpoints .blob }${deploymentStorageContainerName }'
71+ authentication : {
72+ type : identityType == 'SystemAssigned' ? 'SystemAssignedIdentity' : 'UserAssignedIdentity'
73+ userAssignedIdentityResourceId : identityType == 'UserAssigned' ? identityId : ''
74+ }
75+ }
76+ }
77+ scaleAndConcurrency : {
78+ instanceMemoryMB : instanceMemoryMB
79+ maximumInstanceCount : maximumInstanceCount
80+ }
81+ runtime : {
82+ name : runtimeName
83+ version : runtimeVersion
84+ }
85+ }
86+ appSettingsKeyValuePairs : union (appSettings ,
3087 {
88+ AzureWebJobsStorage__blobServiceUri : stg .properties .primaryEndpoints .blob
89+ AzureWebJobsStorage__queueServiceUri : stg .properties .primaryEndpoints .queue
90+ AzureWebJobsStorage__tableServiceUri : stg .properties .primaryEndpoints .table
91+ AzureWebJobsStorage__credential : 'managedidentity'
3192 AzureWebJobsStorage__clientId : identityClientId
93+ APPLICATIONINSIGHTS_CONNECTION_STRING : applicationInsights .properties .ConnectionString
3294 APPLICATIONINSIGHTS_AUTHENTICATION_STRING : applicationInsightsIdentity
95+ AzureWebJobsFeatureFlags : 'EnableWorkerIndexing'
3396 AZURE_OPENAI_KEY : listKeys (aiServicesId , '2025-04-01-preview' ).key1
97+ PYTHON_ENABLE_WORKER_EXTENSIONS : '1'
3498 })
35- applicationInsightsName : applicationInsightsName
36- appServicePlanId : appServicePlanId
37- runtimeName : runtimeName
38- runtimeVersion : runtimeVersion
39- storageAccountName : storageAccountName
40- deploymentStorageContainerName : deploymentStorageContainerName
41- virtualNetworkSubnetId : virtualNetworkSubnetId
42- instanceMemoryMB : instanceMemoryMB
43- maximumInstanceCount : maximumInstanceCount
99+ virtualNetworkSubnetId : !empty (virtualNetworkSubnetId ) ? virtualNetworkSubnetId : null
100+ siteConfig : {
101+ alwaysOn : false
102+ }
44103 }
45104}
46105
47106output SERVICE_API_NAME string = api .outputs .name
48- output SERVICE_API_IDENTITY_PRINCIPAL_ID string = api .outputs .identityPrincipalId
107+ output SERVICE_API_IDENTITY_PRINCIPAL_ID string = identityType == 'SystemAssigned' ? api .outputs .? systemAssignedMIPrincipalId ?? '' : ''
0 commit comments