Reputation: 95
When deploying a function app using bicep code - is it necessary to include the "enabled" parameter and set it to true for the function app to work or can you just leave it out (if it's enabled by default)? Link to documentation: https://learn.microsoft.com/en-us/azure/templates/microsoft.web/sites?pivots=deployment-language-bicep
Upvotes: 0
Views: 191
Reputation: 8018
Site properities of Function App.
Set "enabled" parameter to true
if you want to enable the function App. Otherwise, it will set to the default value which is false
. If you are not enabling it to true
then the function App won't run and shows offline.
Modify the properities as shown:
properties: {
enabled: true
httpsOnly: true
}
Try below code to deploy a function app in bicep:
param appName string = '<appname>'
param storageAccountType string = 'Standard_LRS'
param location string = resourceGroup().location
param appInsightsLocation string
param runtime string = 'dotnet'
var functionAppName = <appName>
var hostingPlanName = <appName>
var applicationInsightsName = <appName>
var storageAccountName = '<storageaccountName>'
var functionWorkerRuntime = dotnet
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = {
name: <storageAccountName>
location: location
sku: {
name: storageAccountType
}
kind: 'Storage'
}
resource hostingPlan 'Microsoft.Web/serverfarms@2021-03-01' = {
name: <hostingPlanName>
location: location
sku: {
name: 'Y1'
tier: 'Dynamic'
}
properties: {}
}
resource functionApp 'Microsoft.Web/sites@2021-03-01' = {
name: functionAppName
location: location
kind: 'functionapp'
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: hostingPlan.id
enabled : true
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: 'FUNCTIONS_EXTENSION_VERSION'
value: '~3'
}
{
name: 'WEBSITE_NODE_DEFAULT_VERSION'
value: '~10'
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: applicationInsights.properties.InstrumentationKey
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: dotnet
}
]
ftpsState: 'FtpsOnly'
minTlsVersion: '1.2'
}
httpsOnly: true
}
}
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: applicationInsightsName
location: appInsightsLocation
kind: 'web'
properties: {
Application_Type: 'web'
Request_Source: 'rest'
}
}
Output:
Deployed successfully in Portal:
Refer MSDoc for a bicep template.
Upvotes: 0