Home > Blockchain >  Azure Functionapp Deployment using Bicep: Properties object is not present in the request body
Azure Functionapp Deployment using Bicep: Properties object is not present in the request body

Time:11-23

I am trying to deploy a new Azure FunctionApp using a bicep File to describe the resources using Infrastrucure-as-code. Here is the bicep file:

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, I am always getting the following error when deploying it

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)

Although properties object is clearly defined. When I omit the whole properties object I receive an error that properties is a value it should not be (probably null). Any ideas?

CodePudding user response:

Check the deployment operations as advised (enter image description here

CodePudding user response:

Below is the sample code for deploying Azure Function App using BICEP. Which will help you in resolving the your issue.

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 find the complete information from this doc and also check this doc with the related information.

  • Related