@@ -65,12 +65,14 @@ resource storageBlobDataContributorRoleAssignment 'Microsoft.Authorization/roleA
6565}
6666
6767// Create a hosting plan for the function app
68+ // Using Flex Consumption plan for serverless hosting with enhanced features
69+ // Reference: https://learn.microsoft.com/en-us/azure/azure-functions/flex-consumption-plan
6870resource hostingPlan 'Microsoft.Web/serverfarms@2024-11-01' = {
6971 name : hostingPlanName
7072 location : location
7173 sku : {
72- name : 'Y1 '
73- tier : 'Dynamic '
74+ name : 'FC1 '
75+ tier : 'FlexConsumption '
7476 }
7577 properties : {
7678 reserved : true
@@ -90,18 +92,10 @@ resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
9092
9193// Construct the app settings
9294var common_settings = [
93- {
94- name : 'FUNCTIONS_EXTENSION_VERSION'
95- value : '~4'
96- }
9795 {
9896 name : 'APPINSIGHTS_INSTRUMENTATIONKEY'
9997 value : applicationInsights .properties .InstrumentationKey
10098 }
101- {
102- name : 'FUNCTIONS_WORKER_RUNTIME'
103- value : 'python'
104- }
10599 // Pass the blob container name to the function app - this is the
106100 // container which is monitored for new packages.
107101 {
@@ -129,17 +123,42 @@ var app_settings = use_shared_keys ? concat(common_settings, [
129123 name : 'AzureWebJobsStorage__accountName'
130124 value : storageAccount .name
131125 }
132- {
133- name : 'WEBSITE_RUN_FROM_PACKAGE'
134- value : 'https://${storageAccount .name }.blob.${environment ().suffixes .storage }/${pythonContainer .name }/function_app.zip'
135- }
136- // Pass the container URL to the function app for the `from_container_url` call.
137126 {
138127 name : 'BLOB_CONTAINER_URL'
139128 value : 'https://${storageAccount .name }.blob.${environment ().suffixes .storage }/${packageContainer .name }/'
140129 }
141130])
142131
132+ var function_runtime = {
133+ name : 'python'
134+ version : python_version
135+ }
136+
137+ var flex_deployment_configuration = {
138+ storage : {
139+ type : 'blobContainer'
140+ value : 'https://${storageAccount .name }.blob.${environment ().suffixes .storage }/${pythonContainer .name }'
141+ authentication : {
142+ type : 'SystemAssignedIdentity'
143+ }
144+ }
145+ }
146+
147+ var flex_scale_and_concurrency = {
148+ maximumInstanceCount : 100
149+ instanceMemoryMB : 2048
150+ }
151+
152+ var function_app_config = use_shared_keys ? {
153+ runtime : function_runtime
154+ scaleAndConcurrency : flex_scale_and_concurrency
155+ } : union ({
156+ runtime : function_runtime
157+ scaleAndConcurrency : flex_scale_and_concurrency
158+ }, {
159+ deployment : flex_deployment_configuration
160+ })
161+
143162// Create the function app.
144163resource functionApp 'Microsoft.Web/sites@2024-11-01' = {
145164 name : functionAppName
@@ -152,13 +171,12 @@ resource functionApp 'Microsoft.Web/sites@2024-11-01' = {
152171 properties : {
153172 serverFarmId : hostingPlan .id
154173 siteConfig : {
155- linuxFxVersion : 'Python|${python_version }'
156- pythonVersion : python_version
157174 appSettings : app_settings
158175 ftpsState : 'FtpsOnly'
159176 minTlsVersion : '1.2'
160177 }
161178 httpsOnly : true
179+ functionAppConfig : function_app_config
162180 }
163181}
164182
0 commit comments