Azure Application Insights警报是否可以触发另一个功能?

时间:2018-06-08 07:57:12

标签: azure azure-functions azure-application-insights azure-logic-apps

我想使用Application Insights来监控链接多个Azure功能的逻辑应用程序。我希望链尽可能安全,如果出现问题,我想让http请求无法被函数正确处理。 我想我可以在出现问题时从Application Insights发出警报,但是我不知道如何将失败的消息发送到blob或“失败的消息队列”。

Application Insights Alert是否可以成为将数据添加到blob的函数的触发器?

1 个答案:

答案 0 :(得分:1)

可以从警报刀片中定义具有功能触发操作类型的操作组。如下图所示,无法在该功能上启用App Service Auth。

enter image description here

您还可以从Google Analytics中创建的自定义查询中提醒警报。例如。搜索包含单词“Error”的最后一小时的所有跟踪日志:

traces |
where message contains "Error" and timestamp >= ago(1h)

enter image description here

保存查询并创建新的警报规则,并将该查询用作警报标准。

访问您的函数中的事件内容:

HttpRequestMessageFeature feature = new HttpRequestMessageFeature(request.HttpContext);
HttpRequestMessage req = feature.HttpRequestMessage;

var content = await req.Content.ReadAsStringAsync();

然后使用WindowsAzure.Storage SDK将内容推送到blob。

var blobClient = storageAccount.CreateCloudBlobClient();
var container = blobClient.GetContainerReference(containerName);

var blockBlob = container.GetBlockBlobReference(fileName);
await blockBlob.UploadTextAsync(content).ConfigureAwait(false);