Problem
I’m trying to deploy a new Azure FunctionApp utilizing Infrastructure-as-code and a bicep File to define the resources. The biceps file is as follows:
param name string
param location string = resourceGroup().location
param serverFarmID string
resource functionApp 'Microsoft.Web/sites@2021-02-01' = {
name: name
location: location
kind: 'functionapp'
properties: {
serverFarmId: serverFarmID
enabled: true
reserved: true
siteConfig: {
appSettings: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=censored;AccountKey= censored;EndpointSuffix=core.windows.net'
}
{
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
value: 'DefaultEndpointsProtocol=https;AccountName=censored;AccountKey= censored;EndpointSuffix=core.windows.net'
}
{
name: 'WEBSITE_CONTENTSHARE'
value: 'examplefunction'
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'node'
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~3'
}
{
name: 'WEBSITE_NODE_DEFAULT_VERSION'
value: '~12'
}
]
}
}
}
However, when I try to deploy it, I always get the following problem.
Status Message: At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details. (Code: DeploymentFailed)
- {
"Code": "BadRequest",
"Message": "Properties object is not present in the request body.",
"Target": null,
"Details": [
{
"Message": "Properties object is not present in the request body."
},
{
"Code": "BadRequest"
},
{
"ErrorEntity": {
"ExtendedCode": "51006",
"MessageTemplate": "{0} object is not present in the request body.",
"Parameters": [
"Properties"
],
"Code": "BadRequest",
"Message": "Properties object is not present in the request body."
}
}
],
"Innererror": null
} (Code:BadRequest)
Despite the fact that the object’s characteristics are explicitly stated. When I don’t include the entire properties object, I get an error saying that properties is a value that shouldn’t be there (probably null). Do you have any suggestions?
Update: The functionApp section worked perfectly and was not the issue. I had another resource in the bicep file that I had forgotten about, and it was missing the properties object. I didn’t notice it because it was at the end of the file and just had four lines. Thank you to everyone who participated.
Asked by DrEichenbach
Solution #1
The sample code for launching an Azure Function App using BICEP is shown below. Which will assist you in fixing your problem.
var location = resourceGroup().location
var suffix = 'azeusfunctionappdev01'
resource storage_account 'Microsoft.Storage/storageAccounts@2020-08-01-preview' = {
name: 'stg${suffix}'
location: location
properties: {
supportsHttpsTrafficOnly: true
minimumTlsVersion: 'TLS1_2'
}
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
}
resource hosting_plan 'Microsoft.Web/serverfarms@2020-06-01' = {
name: 'asp-${suffix}'
location: location
sku: {
name: 'Y1'
tier: 'Dynamic'
}
}
resource function_app 'Microsoft.Web/sites@2020-06-01' = {
name: 'functionapp-${suffix}'
location: location
kind: 'functionapp'
properties: {
httpsOnly: true
serverFarmId: hosting_plan.id
clientAffinityEnabled: true
siteConfig: {
appSettings: [
{
'name': 'FUNCTIONS_EXTENSION_VERSION'
'value': '~3'
}
{
'name': 'FUNCTIONS_WORKER_RUNTIME'
'value': 'powershell'
}
{
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
value: 'DefaultEndpointsProtocol=https;AccountName=${storage_account.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${listKeys(storage_account.id, storage_account.apiVersion).keys[0].value}'
}
{
name: 'WEBSITE_CONTENTSHARE'
value: '${substring(uniqueString(resourceGroup().id), 3)}-azeus-functionapp-dev01'
}
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storage_account.name};AccountKey=${listKeys(storage_account.id, storage_account.apiVersion)};EndpointSuffix=core.windows.net'
}
]
}
}
dependsOn: [
hosting_plan
storage_account
]
}
Also here is the command to deploy the function
PS C:\> New-AzResourceGroupDeployment -ResourceGroupName "rg-azeusfunctionappdev01" -TemplateFile .\Main.json -Debug
Please discover the whole information in this file and compare it to the related information in this doc.
Answered by SaiSakethGuduru-MT
Solution #2
As suggested, check the deployment operations (https://aka.ms/DeployOperations). Check the “Deployments” section of the resource group where you deploy to see why the deployment failed.
Answered by Peter
Post is based on https://stackoverflow.com/questions/70065547/azure-functionapp-deployment-using-bicep-properties-object-is-not-present-in-th