Bicep - Azure Function App Deployment as Container with Quickstart image

Pavlos Theogiannis 0 Reputation points
2025-03-26T13:31:19.1666667+00:00

Dears,

I am struggling with a weird issue when i try to deploy an Azure function resource using bicep.

My intention is to deploy a resource with publishing model: Container and a quickstart image. These details will change afterwards by the vendor.

I have managed to successfully create my module and deploy the resource by using deployment method code without any issues using the following module:

/*
Version: 2.0

Microsoft Documentation
https://learn.microsoft.com/en-us/azure/templates/microsoft.web/sites

*/

import { NamingOutput } from '../../Naming/naming_module.bicep'
param naming NamingOutput


param globalParams object
param functionAppServicePlanID string
param functionAppName string
param functionAppParams object
param managedIdentityId string
param storageAccountName string
param virtualNetworkSubnetId string
var identityType = functionAppParams.identity.type


resource storageaccount 'Microsoft.Storage/storageAccounts@2023-04-01' existing=  {
  name: storageAccountName
  }

resource functionApp 'Microsoft.Web/sites@2023-12-01' = {
  name: replace(naming.functionApp.name, '0ph0', functionAppName)
  location: globalParams.location
  identity: {
    type: functionAppParams.identity.type
    userAssignedIdentities: identityType == 'UserAssigned' || identityType == 'SystemAssigned, UserAssigned' ? {
      '${managedIdentityId}': {} 
    } : null
  }
  kind: functionAppParams.kind
  properties: {
    serverFarmId: functionAppServicePlanID
    siteConfig: {
      appSettings: [
        {
          name: 'AzureWebJobsStorage'
          value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageaccount.listKeys().keys[0].value}'
        }
        {
          name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
          value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageaccount.listKeys().keys[0].value}'
        }
        {
          name: 'WEBSITE_CONTENTSHARE'
          value: toLower(replace(naming.functionApp.name, '0ph0', functionAppName))
        }
        {
          name: 'FUNCTIONS_EXTENSION_VERSION'
          value: '~4'
        }
        //For Vnet Integration and private Endpoint access to Storage
        {
          name: 'WEBSITE_CONTENTOVERVNET'
          value: '1'
        }
        {
          name: 'WEBSITE_DNS_SERVER'
          value: '168.63.129.16'
        }
        {
          name: 'WEBSITE_VNET_ROUTE_ALL'
          value: '1'
        }
        // {
        //   name: 'WEBSITE_NODE_DEFAULT_VERSION'
        //   value: '~14'
        // }
        {
          name: 'FUNCTIONS_WORKER_RUNTIME'
          value: 'dotnet-isolated'//functionWorkerRuntime
        }
        {
          name: 'WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED'
          value: '1'
        }
      ]
      ftpsState: 'FtpsOnly'
      minTlsVersion: '1.2'
    }
    httpsOnly: true
    publicNetworkAccess: 'Disabled'
    //for vnet integration
    virtualNetworkSubnetId: virtualNetworkSubnetId 
  }
}


resource SCMCredentialPolicy 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2023-12-01' = {
  parent:functionApp
  name: 'scm'
  properties: {
    allow: false
  }
}

resource FTPCredentialPolicy 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2023-12-01' = {
  parent: functionApp
  name: 'ftp'
  properties: {
    allow: false
  }
}


output functionAppID string = functionApp.id
output functionAppName string = functionApp.name

But when i try to change my module to have the deployment model set to Container by setting linuxFxVersion i receive the following error:

The parameter LinuxFxVersion has an invalid value.

The strange thing is that i take the exact value produced by a deployment through GUI, that deploys the resource just fine. I've been trying several days to figure it out but no luck so far. Anyone faced the same issue and has any clue how to fix this? I tried deploying with Docker image settings section on and off. If i completely remove LinuxFxVersion the deployment succeeds but the publishing mode is code again.

my App Service Plan if it matters is ElasticPremium tier

My code is the following:

param globalParams object
param functionAppServicePlanID string
param functionAppName string
param functionAppParams object
param managedIdentityId string
param storageAccountName string
param virtualNetworkSubnetId string

var identityType = functionAppParams.identity.type

resource storageaccount 'Microsoft.Storage/storageAccounts@2023-04-01' existing=  {
  name: storageAccountName
  }

resource functionApp 'Microsoft.Web/sites@2024-04-01' = {
  name: replace(naming.functionApp.name, '0ph0', functionAppName)
  location: globalParams.location
  kind: 'functionapp,linux,container'
  identity: {
    type: functionAppParams.identity.type
    userAssignedIdentities: identityType == 'UserAssigned' || identityType == 'SystemAssigned, UserAssigned' ? {
      '${managedIdentityId}': {} 
    } : null
  }
  properties: {

    serverFarmId: functionAppServicePlanID
    reserved: true
    isXenon: false
    hyperV: false

    siteConfig: {
      numberOfWorkers: 1
      netFrameworkVersion: 'v4.0'
      linuxFxVersion: 'DOCKER|mcr.microsoft.com/azure-functions/dotnet:4-appservice-quickstart'
      acrUseManagedIdentityCreds: false
      alwaysOn: false
      http20Enabled: false
      functionAppScaleLimit: 0
      minimumElasticInstanceCount: 1
      appSettings: [
        {
          name: 'AzureWebJobsStorage'
          value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageaccount.listKeys().keys[0].value}'
        }
        {
          name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
          value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageaccount.listKeys().keys[0].value}'
        }
        {
          name: 'WEBSITE_CONTENTSHARE'
          value: toLower(replace(naming.functionApp.name, '0ph0', functionAppName))
        }
        {
          name: 'FUNCTIONS_EXTENSION_VERSION'
          value: '~4'
        }
        //For Vnet Integration and  access to Storage with Private Endpoint.
        {
          name: 'WEBSITE_CONTENTOVERVNET'
          value: '1'
        }
        {
          name: 'WEBSITE_DNS_SERVER'
          value: '168.63.129.16'
        }
        {
          name: 'WEBSITE_VNET_ROUTE_ALL'
          value: '1'
        }
        //Docker image settings
      {
          name: 'DOCKER_REGISTRY_SERVER_URL'
          value: 'mcr.microsoft.com'
      }
      {
          name: 'DOCKER_REGISTRY_SERVER_USERNAME'
          value: ''
      }
      {
          name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
          value: ''
      }
      {
          name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
          value: 'false'
      }
      {
          name: 'FUNCTIONS_WORKER_RUNTIME'
          value: 'dotnet-isolated'//functionWorkerRuntime
      }
      ] 
    }
   
    httpsOnly: true
    publicNetworkAccess: 'Disabled'
    virtualNetworkSubnetId: virtualNetworkSubnetId
  }

}

resource FTPCredentialPolicy 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2024-04-01' = {
  parent: functionApp
  name: 'ftp'
  properties: {
    allow: false
  }
}

resource SCMCredentialPolicy 'Microsoft.Web/sites/basicPublishingCredentialsPolicies@2024-04-01' = {
  parent: functionApp
  name: 'scm'
  properties: {
    allow: false
  }
}

output functionAppID string = functionApp.id
output functionAppName string = functionApp.name
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,911 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Khadeer Ali 5,990 Reputation points Microsoft External Staff Moderator
    2025-03-26T15:09:45.5366667+00:00

    @Pavlos Theogiannis ,

    I’m glad to hear that you were able to resolve your issue and thank you for sharing your solution! It’s great to see your contribution, as it helps others in the community who may face a similar issue. Since the Microsoft Q&A community policy states, "The question author cannot accept their own answer—they can only accept answers by others," I’m reposting your solution here so you can mark it as accepted if it resolves your query:

    Reposted Solution:

    "For those who might face the same issue i was deploying the asp with kind elastic and i never noticed that it lead to deploying the asp plan with Windows OS hence it was not possible for the azure function to create a linux based container that i needed in my case. I've changed it to elastic, linux and it works fine now."

    If you have any further questions, feel free to reach out.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.