Skip to content

Commit f5da37b

Browse files
Fixed Azure.AppService.AvailabilityZone only detects premium by tier (Azure#3036)
* Fixed Azure.AppService.AvailabilityZone only detects premium by tier property * Update tests/PSRule.Rules.Azure.Tests/Azure.AppService.Tests.ps1 Co-authored-by: Bernie White <[email protected]> * Update src/PSRule.Rules.Azure/rules/Azure.AppService.Rule.ps1 Co-authored-by: Bernie White <[email protected]> --------- Co-authored-by: Bernie White <[email protected]>
1 parent 7a8edb6 commit f5da37b

File tree

4 files changed

+41
-6
lines changed

4 files changed

+41
-6
lines changed

docs/CHANGELOG-v1.md

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ See [upgrade notes][1] for helpful information when upgrading from previous vers
3535
[#432](https://github.com/Azure/PSRule.Rules.Azure/issues/432)
3636
- Verify that availability set members are in a backend pool by @BenjaminEngeset.
3737
[#67](https://github.com/Azure/PSRule.Rules.Azure/issues/67)
38+
- Bug fixed:
39+
- Fixed `Azure.AppService.AvailabilityZone` only detects premium by tier property @BenjaminEngeset.
40+
[#3034](https://github.com/Azure/PSRule.Rules.Azure/issues/3034)
3841

3942
## v1.39.0-B0055 (pre-release)
4043

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

+36-4
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,42 @@ Rule 'Azure.AppService.AvailabilityZone' -Ref 'AZR-000442' -Type 'Microsoft.Web/
201201
}
202202

203203
# Availability zones are only supported for these Premium SKUs.
204-
$Assert.In($TargetObject, 'sku.tier', @('PremiumV2', 'PremiumV3', 'ElasticPremium')).Reason(
205-
$LocalizedData.AppServiceAvailabilityZoneSKU,
206-
$TargetObject.name
207-
)
204+
$sku = [PSCustomObject]@{
205+
name = @(
206+
'P1v3'
207+
'P1mv3'
208+
'P2v3'
209+
'P2mv3'
210+
'P3v3'
211+
'P3mv3'
212+
'P4mv3'
213+
'P5mv3'
214+
'P1v2'
215+
'P2v2'
216+
'P3v2'
217+
'EP1'
218+
'EP2'
219+
'EP3'
220+
)
221+
tier = @(
222+
'PremiumV3'
223+
'PremiumV2'
224+
'ElasticPremium'
225+
)
226+
}
227+
228+
AnyOf {
229+
$Assert.In($TargetObject, 'sku.name', $sku.name).ReasonFrom(
230+
'sku.name',
231+
$LocalizedData.AppServiceAvailabilityZoneSKU,
232+
$TargetObject.name
233+
)
234+
$Assert.In($TargetObject, 'sku.tier', $sku.tier).ReasonFrom(
235+
'sku.tier',
236+
$LocalizedData.AppServiceAvailabilityZoneSKU,
237+
$TargetObject.name
238+
)
239+
}
208240

209241
$Assert.HasFieldValue($TargetObject, 'properties.zoneRedundant', $true)
210242
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ Describe 'Azure.AppService' -Tag 'AppService' {
265265
$ruleResult.TargetName | Should -Be 'plan-A', 'plan-D';
266266

267267
$ruleResult[0].Reason | Should -BeExactly @(
268-
"The app service plan (plan-A) is not deployed with a SKU that supports zone-redundancy."
268+
"Path sku.name: The app service plan (plan-A) is not deployed with a SKU that supports zone-redundancy."
269+
"Path sku.tier: The app service plan (plan-A) is not deployed with a SKU that supports zone-redundancy."
269270
"Path properties.zoneRedundant: Does not exist."
270271
);
271272
$ruleResult[1].Reason | Should -BeExactly "Path properties.zoneRedundant: Is set to 'False'.";

tests/PSRule.Rules.Azure.Tests/Resources.AppService.json

-1
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,6 @@
632632
},
633633
"Sku": {
634634
"name": "P1v3",
635-
"tier": "PremiumV3",
636635
"size": "P1v3",
637636
"family": "Pv3",
638637
"capacity": 1

0 commit comments

Comments
 (0)