Skip to content

Commit a086ba2

Browse files
authored
Updated Azure.ContainerApp.AvailabilityZone to check for infrastructure subnet Azure#3068 (Azure#3071)
1 parent 3309387 commit a086ba2

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

docs/CHANGELOG-v1.md

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ See [upgrade notes][1] for helpful information when upgrading from previous vers
3131

3232
What's changed since pre-release v1.39.0-B0118:
3333

34+
- Updated rules:
35+
- Container Apps:
36+
- Updated `Azure.ContainerApp.AvailabilityZone` to check for infrastructure subnet by @BernieWhite.
37+
[#3068](https://github.com/Azure/PSRule.Rules.Azure/issues/3068)
38+
- Configuring an infrastructure subnet is a requirement for enabling zone redundancy.
39+
Both rule and documentation have been updated to clearly call this out.
3440
- Engineering:
3541
- Quality updates to rule documentation by @BernieWhite.
3642
[#2570](https://github.com/Azure/PSRule.Rules.Azure/issues/2570)

docs/en/rules/Azure.ContainerApp.AvailabilityZone.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
reviewed: 2024-04-07
2+
reviewed: 2024-10-01
33
severity: Important
44
pillar: Reliability
55
category: RE:05 Regions and availability zones
@@ -16,14 +16,21 @@ Use Container Apps environments that are zone redundant to improve reliability.
1616
## DESCRIPTION
1717

1818
Container App environments can be configured to be zone redundant in regions that support availability zones.
19+
Zone redundancy is supported in both the workload profiles and consumption only environments.
1920
When configured, replicas of each Container App are spread across availability zones automatically.
2021
A Container App must have multiple replicas to be zone redundant.
2122

22-
For example, if a Container App has three replicas, each replica is placed in a different availability zone.
23+
For example:
24+
25+
- If a Container App has three replicas, each replica is placed in a different availability zone.
26+
- If a Container App has one replica, it is only available in a single zone.
27+
28+
Zone redundancy can only be enabled at initial environment creation.
29+
Additionally, the Container App environment must be deployed with an infrastructure subnet configured.
2330

2431
## RECOMMENDATION
2532

26-
Consider configuring Container App environments to be zone redundant to improve reliability.
33+
Consider configuring Container App environments to be zone redundant to improve workload resiliency.
2734

2835
## EXAMPLES
2936

@@ -32,6 +39,7 @@ Consider configuring Container App environments to be zone redundant to improve
3239
To deploy Container App environments that pass this rule:
3340

3441
- Set the `properties.zoneRedundant` property to `true`.
42+
- Set the `properties.vnetConfiguration.infrastructureSubnetId` property to reference a valid subnet.
3543

3644
For example:
3745

@@ -69,6 +77,7 @@ For example:
6977
To deploy Container App environments that pass this rule:
7078

7179
- Set the `properties.zoneRedundant` property to `true`.
80+
- Set the `properties.vnetConfiguration.infrastructureSubnetId` property to reference a valid subnet.
7281

7382
For example:
7483

@@ -99,7 +108,7 @@ resource containerEnv 'Microsoft.App/managedEnvironments@2023-05-01' = {
99108
}
100109
```
101110

102-
<!-- external:avm avm/res/app/managed-environment:0.8.0 zoneRedundant -->
111+
<!-- external:avm avm/res/app/managed-environment:0.8.0 zoneRedundant,vnetConfiguration.infrastructureSubnetId -->
103112

104113
## LINKS
105114

src/PSRule.Rules.Azure/rules/Azure.ContainerApp.Rule.ps1

+3-2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Rule 'Azure.ContainerApp.AvailabilityZone' -Ref 'AZR-000414' -Type 'Microsoft.Ap
3030
}
3131

3232
$Assert.HasFieldValue($TargetObject, 'properties.zoneRedundant', $True);
33+
$Assert.HasFieldValue($TargetObject, 'properties.vnetConfiguration.infrastructureSubnetId');
3334
}
3435

3536
#endregion Rules
@@ -38,9 +39,9 @@ Rule 'Azure.ContainerApp.AvailabilityZone' -Ref 'AZR-000414' -Type 'Microsoft.Ap
3839

3940
function global:HasIngress {
4041
[CmdletBinding()]
41-
param ()
42+
param ()
4243
process {
43-
$Assert.HasField($TargetObject, 'properties.configuration.ingress').Result
44+
$Assert.HasField($TargetObject, 'properties.configuration.ingress').Result
4445
}
4546
}
4647

tests/PSRule.Rules.Azure.Tests/Azure.ContainerApp.Tests.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Describe 'Azure.ContainerApp' -Tag 'ContainerApp' {
197197
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Fail' });
198198
$ruleResult.Length | Should -Be 2;
199199
$ruleResult.TargetName | Should -BeIn 'capp-env-A', 'capp-env-B';
200-
$ruleResult.Detail.Reason.Path | Should -BeIn 'properties.zoneRedundant';
200+
$ruleResult.Detail.Reason.Path | Should -BeIn 'properties.zoneRedundant', 'properties.vnetConfiguration.infrastructureSubnetId';
201201

202202
# Pass
203203
$ruleResult = @($filteredResult | Where-Object { $_.Outcome -eq 'Pass' });

0 commit comments

Comments
 (0)