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