如何在使用 az monitor app-insights 查询时 运行 进行多行查询?

How can I run a multi-line query while using az monitor app-insights query?

如何在使用 az monitor app-insights query 时 运行 进行多行查询?

此单行查询按预期工作:

$query = "requests | summarize count() by bin(timestamp, 1h)"
az monitor app-insights query --app $appId --analytics-query $query --offset 1h30m

此多行查询导致错误:

$query = @"
    requests | 
    summarize count() by bin(timestamp, 1h)
"@
az monitor app-insights query --app $appId --analytics-query $query --offset 1h30m

相关文档:https://docs.microsoft.com/en-us/cli/azure/ext/application-insights/monitor/app-insights?view=azure-cli-latest#ext_application_insights_az_monitor_app_insights_query-examples

这行得通,但我宁愿使用此处的字符串:

$query = 
    "requests | " +
    "summarize count() by bin(timestamp, 1h)"

az monitor app-insights query --app $appId --analytics-query $query --offset 1h30m