I am trying to deploy Azure Functions (Python3.11) using the following Bicep.
param location string = resourceGroup().location
resource storageAccount 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: 'samplestorage123'
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
accessTier: 'Hot'
}
}
resource appServicePlan 'Microsoft.Web/serverfarms@2023-01-01' = {
name: 'testplan'
location: location
kind: 'linux'
sku: {
name: 'Y1'
}
properties: {}
}
resource function 'Microsoft.Web/sites@2023-01-01' = {
name: 'testfunc'
location: location
kind: 'functionapp,linux'
properties: {
enabled: true
serverFarmId: appServicePlan.id
reserved: true
siteConfig: {
appSettings: [
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4'
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'python'
}
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
}
{
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
}
{
name: 'WEBSITE_CONTENTSHARE'
value: 'func001'
}
]
cors: {
allowedOrigins: [
'https://portal.azure.com'
]
}
use32BitWorkerProcess: false
ftpsState: 'Disabled'
pythonVersion: '3.11'
linuxFxVersion: 'Python|3.11'
}
clientAffinityEnabled: false
virtualNetworkSubnetId: null
publicNetworkAccess: 'Enabled'
httpsOnly: true
}
}
But the deployment fails with the following error:
The parameter LinuxFxVersion has an invalid value.
As a test, if I erase the "linuxFxVersion" field, the deployment will succeed. However, when I browse the Azure Portal, I get the error message "Microsoft.Azure.WebJobs.Script: WorkerConfig for runtime: python not found."
Naturally, accessing the site results in an error.
Could someone please provide a bicep template for a successful Python Function?
According to the SO worked by me earlier, I have modified your bicep code as below and the deployment was successful without any issues.
param name string = 'jahnavistoragesceoo'
param location string = 'EastUS'
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
name: name
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
}
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: 'nameapplication-insights'
location: location
kind: 'web'
properties: {
Application_Type: 'web'
Request_Source: 'rest'
}
}
resource hostingPlan 'Microsoft.Web/serverfarms@2021-03-01' = {
name: name
location: location
kind: 'Linux'
sku: {
name: 'Y1'
tier: 'Dynamic'
}
properties: {
reserved: true
}
}
resource functionApp 'Microsoft.Web/sites@2021-03-01' = {
name: name
location: location
kind: 'functionapp'
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: hostingPlan.id
siteConfig: {
pythonVersion: '3.11'
linuxFxVersion: 'python|3.11'
appSettings: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccount.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
}
{
name: 'SCM_DO_BUILD_DURING_DEPLOYMENT'
value: 'true'
}
{
name: 'ENABLE_ORYX_BUILD'
value: 'true'
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4'
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: applicationInsights.properties.InstrumentationKey
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'python'
}
]
}
httpsOnly: true
}
}
Deployment succeeded: