首页 文章

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

提问于
浏览
4

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

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

1 回答

  • 0

    可以从警报刀片定义具有功能触发器操作类型的操作组 . 如下图所示,无法在该功能上启用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);
    

相关问题