【问题标题】:Enable Health Check in a app service via CLI通过 CLI 在应用服务中启用健康检查
【发布时间】:2023-03-22 09:43:01
【问题描述】:

有没有办法通过 cli 在 azure app services 中启用健康检查?我看到我们可以修改一些配置,但不能修改启用/禁用该功能的选项。

谢谢!

【问题讨论】:

标签: azure azure-web-app-service azure-cli health-check


【解决方案1】:

根据我的测试,我们可以通过更改 web config healthCheckPath 的值来启用/禁用健康检查。更多详情请参考here

例如(我通过 azure cloud shell 测试)

一个。启用

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

b.禁用

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

【讨论】:

  • 谢谢@jim-xu 这很有帮助。
【解决方案2】:

感谢@jim-xu 的回答,我能够满足我们的需求。

我确实很难尝试使用字符串引号在现有的 PowerShell 脚本中使用语法并将其设为变量。我想我会把这个语法放在这里,以防其他人通过不使用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

是的,我确实尝试过认真阅读Use Azure CLI effectively - Using quotation marks in values,但我仍然不清楚。

我看到很多其他用户都被这种语法所吸引的帖子; example 1, example 2, example 3.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 2016-08-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多