-
Notifications
You must be signed in to change notification settings - Fork 84
/
Azure.ContainerApp.MinReplicas.md
132 lines (104 loc) · 3.73 KB
/
Azure.ContainerApp.MinReplicas.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
---
reviewed: 2024-04-02
severity: Important
pillar: Reliability
category: RE:05 Redundancy
resource: Container App
online version: https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.ContainerApp.MinReplicas/
---
# Use a minimum number of replicas
## SYNOPSIS
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:
```json
{
"type": "Microsoft.App/containerApps",
"apiVersion": "2023-05-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,
"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:
```bicep
resource containerApp 'Microsoft.App/containerApps@2023-05-01' = {
name: appName
location: location
identity: {
type: 'SystemAssigned'
}
properties: {
environmentId: containerEnv.id
template: {
revisionSuffix: revision
containers: containers
scale: {
minReplicas: 2
}
}
configuration: {
ingress: {
allowInsecure: false
stickySessions: {
affinity: 'none'
}
}
}
}
}
```
<!-- external:avm avm/res/app/container-app scaleMinReplicas -->
### Configure with Azure CLI
```bash
az containerapp update -n '<name>' -g '<resource_group>' --min-replicas 2 --max-replicas 10
```
### Configure with Azure PowerShell
```powershell
Update-AzContainerApp -Name '<name>' -ResourceGroupName '<resource_group>' -ScaleMinReplica 2 -ScaleMaxReplica 10
```
## LINKS
- [RE:05 Redundancy](https://learn.microsoft.com/azure/well-architected/reliability/redundancy)
- [Reliability in Azure Container Apps](https://learn.microsoft.com/azure/reliability/reliability-azure-container-apps#availability-zone-support)
- [Set scaling rules in Azure Container Apps](https://learn.microsoft.com/azure/container-apps/scale-app)
- [Azure deployment reference](https://learn.microsoft.com/azure/templates/microsoft.app/containerapps)