Skip to content

Use a minimum number of replicas#

Reliability · Container App · Rule · 2024_06 · Important

Use multiple replicas to remove a single point of failure.

Description#

When a Container App is deployed Azure create one or more instances or replicas of the application. The number of replicas is configurable and can be automatically scaled up or down based on demand using scaling rules.

When a single instance of the application is deployed, in the event of a failure Azure will replace the instance. However, this can lead to downtime while the instance is replaced with this single point of failure.

To ensure that the application is highly available, it is recommended to configure a minimum number of replicas. The minimum number of replicas required will depend on the criticality of the application and the expected demand.

For a production application, consider configuring a minimum of two (2) replicas. When zone redundancy is configured, use a minimum of three (3) replicas to spread the replicas across all availability zones.

Recommendation#

Consider configuring a minimum number of replicas for the Container App to remove a single point of failure on a single instance.

Examples#

Configure with Azure template#

To deploy Container Apps that pass this rule:

  • Set the properties.template.scale.minReplicas property to a minimum of 2.

For example:

Azure Template snippet
{
  "type": "Microsoft.App/containerApps",
  "apiVersion": "2024-03-01",
  "name": "[parameters('appName')]",
  "location": "[parameters('location')]",
  "identity": {
    "type": "SystemAssigned"
  },
  "properties": {
    "environmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('envName'))]",
    "template": {
      "revisionSuffix": "[parameters('revision')]",
      "containers": "[variables('containers')]",
      "scale": {
        "minReplicas": 2
      }
    },
    "configuration": {
      "ingress": {
        "allowInsecure": false,
        "external": false,
        "ipSecurityRestrictions": "[variables('ipSecurityRestrictions')]",
        "stickySessions": {
          "affinity": "none"
        }
      }
    }
  },
  "dependsOn": [
    "[resourceId('Microsoft.App/managedEnvironments', parameters('envName'))]"
  ]
}

Configure with Bicep#

To deploy Container Apps that pass this rule:

  • Set the properties.template.scale.minReplicas property to a minimum of 2.

For example:

Azure Bicep snippet
resource containerApp 'Microsoft.App/containerApps@2024-03-01' = {
  name: appName
  location: location
  identity: {
    type: 'SystemAssigned'
  }
  properties: {
    environmentId: containerEnv.id
    template: {
      revisionSuffix: revision
      containers: containers
      scale: {
        minReplicas: 2
      }
    }
    configuration: {
      ingress: {
        allowInsecure: false
        external: false
        ipSecurityRestrictions: ipSecurityRestrictions
        stickySessions: {
          affinity: 'none'
        }
      }
    }
  }
}

Configure with Azure Verified Modules

A pre-validated module supported by Microsoft is available from the Azure Bicep public registry. To reference the module, please use the following syntax:

br/public:avm/res/app/container-app:<version>

For example:

br/public:avm/res/app/container-app:0.11.0

To use the latest version:

br/public:avm/res/app/container-app:0.9.0

Configure with Azure CLI#

Azure CLI snippet
az containerapp update -n '<name>' -g '<resource_group>' --min-replicas 2 --max-replicas 10

Configure with Azure PowerShell#

Azure PowerShell snippet
Update-AzContainerApp -Name '<name>' -ResourceGroupName '<resource_group>' -ScaleMinReplica 2 -ScaleMaxReplica 10

Comments