Azure Monitor:查询禁用的功能

Azure Monitor: Query for disabled functions

是否有一种简洁的方法来查询 Azure Monitor 中所有禁用功能的名称?

当然,我可以对名称或函数进行硬编码,并检查是否有函数的日志,但我想有更聪明的方法。

谢谢!

您应该使用 Azure 函数的应用程序见解。详情请关注本article。然后您可以使用下面的查询来获取所有禁用的函数名称。

注意:下面的查询可以在 Application insights 或 Azure Monitor 中 运行。

traces 
//use sdkVersion to ensure it's an anzure function
| where sdkVersion contains "azurefunctions" 
//then check if the message contains the word disabled
| where  message contains "disabled" 
//get the function name from message
| extend functionname=substring(message, 10,indexof(message,"'", 10)-10) 

解释查询:

1.if 功能被禁用,则消息字段应包含 "function xxx is disabled."

等信息

2.to 确保它是一个 azure 函数,我检查字段 sdkVersion 看它是否包含单词 "azurefunctions"

3.at 最后,从消息字段中获取函数名称。

测试结果:

我用函数 v3 对其进行了测试,如果您使用的是 azure 函数 v2 或 v1,您可以(也可以不)稍微修改查询,但这应该很容易。