3

Is there any way to enable health check via cli in azure app services? I see that we can modify some configurations but not an option to enable/disable the feature.

Thank you!

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
Diogo Machado
  • 41
  • 1
  • 2
  • Hi, welcome to StackOverflow! You should add more details such as sample of your code and your execution log as it will help us help you. You can also take the [Tour](https://stackoverflow.com/tour), it will help you understand how to properly ask a question :) – vmf91 Apr 24 '21 at 23:45
  • Have you referred to https://learn.microsoft.com/en-us/answers/questions/232191/app-service-health-check-automation.html? – Jim Xu Apr 26 '21 at 01:15

2 Answers2

7

According to my test, we can enable/disable health check via changing the value of web config healthCheckPath. For more details, please refer to here.

For example(I test it via azure cloud shell)

a. Enable

az webapp config set -g <groupName> -n <web name>    --generic-configurations '{"healthCheckPath": "/api/health/"}'

enter image description here enter image description here

b.Disable

az webapp config set -g <groupName> -n <web name>    --generic-configurations '{"healthCheckPath": ""}'

enter image description here enter image description here

Jim Xu
  • 21,610
  • 2
  • 19
  • 39
1

Thanks to @jim-xu answer I was able to get this working for our needs.

I did struggle trying to make syntax work in an existing PowerShell script with the string quotation marks and making it a variable. I thought I'd put that syntax here in case someone else is trying this via scripts not using bash.

# variables - these might be local or parameters from your function, etc..
$webAppName= "my-web-app"
$resourceGroupName = "my-resource-group"
$healthCheckPath = "/api/health/"

# the important part
$genericConfigurations = "{\""healthCheckPath\"": \""$healthCheckPath\""}"
az webapp config set  --name $webAppName `
                      --resource-group $resourceGroupName `
                      --generic-configurations $genericConfigurations `
                      --output none

Yes I did attempt to be conscientious and read through Use Azure CLI effectively - Using quotation marks in values and it still wasn't clear to me.

I saw many other posts with users getting caught on this syntax; example 1, example 2, example 3.

Rick Glos
  • 2,466
  • 2
  • 29
  • 30