Search code examples
azureazure-resource-managerazure-bicep

When redeploying a consumption function app with Bicep exceeding maximum number of slots


When redeploying an azure function app on a consumption plan with two slots using Bicep I'm receiving this error:

The site(s) '{0}' exceed maximum number of slots allowed for the hosting plan. Remove all deployment slots before scaling to a different mode.

Here is my bicep code:

// app-service-plan-func.bicep
resource appServicePlanFunc 'Microsoft.Web/serverfarms@2021-03-01' = {
  name: name
  location: location
  sku: {
    name: 'Y1'
  }
}

// app-service-app-func.bicep
resource appServicFuncApp 'Microsoft.Web/sites@2021-03-01' = {
    name: name
    location: location
    kind: 'functionapp'
    identity: {
      type: 'SystemAssigned'
    }
    properties: {
      httpsOnly: true
      serverFarmId: appServicePlanFunc.id
      siteConfig: {
        minTlsVersion: '1.2'
        appSettings: [
            {
              'name': 'FUNCTIONS_EXTENSION_VERSION'
              'value': '~4'
            }
            {
              'name': 'FUNCTIONS_WORKER_RUNTIME'
              'value': 'dotnet'
            }]
      }
    }
  }

// app-service-slot-func.bicep
resource appServiceSlot 'Microsoft.Web/sites/slots@2021-03-01' = {
  name: slotName
  location: location
  parent: appServicFuncApp
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    enabled: true
    httpsOnly: true
    serverFarmId: appServicePlanFunc.id
  }
}

It works the first time I provision it, only on subsequent deployments it fails.


Solution

  • Thank you @Thomas,For pointing out to the right document, Posting your suggestions as an answer so that it can be benifit for other community members.

    When redeploying an azure function app on a consumption plan with two slots using Bicep I'm receiving this error:

    Based on the MICROSOFT DOCUMENTATION:-

    The plan that you are using is consumption , And it supported only one deployment slots as we have one production lot by default. To use Additional slots that are available for apps running under other plans. For details, see Service limits.

    For more information please refer the below links:-