Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Azure.AppService.WebProbe failing while healthCheckPath being set. #1906

Closed
vinhent opened this issue Nov 25, 2022 · 4 comments · Fixed by #1908
Closed

Azure.AppService.WebProbe failing while healthCheckPath being set. #1906

vinhent opened this issue Nov 25, 2022 · 4 comments · Fixed by #1908
Assignees
Labels
bug Something isn't working rule: app-service Rules for App Service
Milestone

Comments

@vinhent
Copy link

vinhent commented Nov 25, 2022

Description of the issue

I am getting a failed on healthCheckPath while it's set to a path.

To Reproduce

Steps to reproduce the issue:

  1. Create a module that defines an app service plan and web apps.
  2. Add a parameter for healthCheckPath.
  3. Create a parameter file with a value for healthCheckPath.
param healthCheckPath string = ''

resource webApps 'Microsoft.Web/sites@2021-03-01' = [for webAppName in webAppNames: {
  name: webAppName
  location: location
  tags: tags
  properties: {
    enabled: true
    serverFarmId: plan.id
    siteConfig: {
      healthCheckPath: '/api/help'
      autoHealEnabled: true
    }
    clientAffinityEnabled: false
    httpsOnly: true
  }
  identity: {
    type: 'SystemAssigned'
  }
}]

Expected behaviour

Test should pass since a value is set in healthCheckPath.

Error output

[FAIL] Azure.AppService.WebProbe (AZR-000079)
| Template: modules/appService.bicep:258:5
| Parameter: tests/appService.parameters.json:1:0

| RECOMMEND:
| Consider configuring a health probe to monitor instance availability.

| REASON:
| - Path Properties.siteConfig.healthCheckPath: Is set to '/api/help'.

| HELP:
| - https://azure.github.io/PSRule.Rules.Azure/en/rules/Azure.AppService.WebProbe/

[error]AZR-000079: cic-test-app failed Azure.AppService.WebProbe. Configure and enable instance health probes.
[error]AZR-000079: cic-test-app failed Azure.AppService.WebProbe. Configure and enable instance health probes.

Module in use and version:

  • Module: PSRule.Rules.Azure
  • Version: [e.g. 1.21.2]

Captured output from $PSVersionTable:


Additional context

@vinhent vinhent added the bug Something isn't working label Nov 25, 2022
@yzhu228
Copy link

yzhu228 commented Nov 26, 2022

I had the same issue before.

A workaround is to avoid using the siteConfig within Microsoft.Web/sites resource. Instead using the Microsoft.Web/sites/config and set the healthCheckPath under its properties.

This I think it is a bug, on the line

return $Assert.HasFieldValue($TargetObject, 'Properties.siteConfig.healthCheckPath', $True);

@BenjaminEngeset
Copy link
Contributor

From what I can see so far, the rule is expecting the value to be boolean true, where actually the healthCheckPath property is expecting a value of type string. So your valid value is not honored currently.

I'll wait for @BernieWhite to confirm that this is the case and I'll put together an PR.

@yzhu228
Copy link

yzhu228 commented Nov 26, 2022

I have a double on the necessity of having two rules Azure.AppService.WebProbe and Azure.AppService.WebProbePath of overlapped purpose, one for the healthCheckPath's existence while another is for it's not empty.

Is there any reason we have these 2 rules instead of consolidating them into 1?

@BernieWhite
Copy link
Collaborator

@vinhent Thanks for reporting the issue. This is a bug.

@yzhu228 and @BenjaminEngeset are correct, the rule is checking for true instead of a string for the property Properties.siteConfig.healthCheckPath.

return $Assert.HasFieldValue($TargetObject, 'Properties.siteConfig.healthCheckPath', $True);

Line 115 should be updated to be:

return $Assert.HasFieldValue($TargetObject, 'Properties.siteConfig.healthCheckPath');

In this rule we are checking that a health probe is configured.


@yzhu228 In regard to your question about why is there two rules. This is because while using a dedicated health check path (such as /healthz) is the recommended practise from the WAF, it is not always possible due to third-party applications or legacy code.

Providing two rules give the customer an opportunity to suppress this rule for cases where a dedicated endpoint is not possible but still required a health check to be configured.

@BernieWhite BernieWhite added the rule: app-service Rules for App Service label Nov 27, 2022
@BernieWhite BernieWhite self-assigned this Nov 27, 2022
@BernieWhite BernieWhite added this to the v1.22.0 milestone Nov 27, 2022
BernieWhite added a commit to BernieWhite/PSRule.Rules.Azure that referenced this issue Nov 27, 2022
This was referenced Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working rule: app-service Rules for App Service
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants