gpt4 book ai didi

Azure Blob 存储 - 当新文件上传到 Blob 容器中的特定文件夹时设置警报

转载 作者:行者123 更新时间:2023-12-04 00:05:51 25 4
gpt4 key购买 nike

在 Azure 中,我有一个存储帐户,用于从 IoT 设备上传文件。当物联网设备检测到某些条件时发送文件。所有文件都上传到同一个 Blob 容器和同一个文件夹(Blob 容器内)。

我想要做的是当新文件上传到 Blob 容器时自动发送电子邮件(作为警报)。我已检查了 Azure 提供的用于在存储帐户(在 Azure 门户中)中设置警报的不同选项,但我没有发现任何有用的内容。

我如何创建这种警报?

最佳答案

据我所知,azure提供了azure功能或webjobs,当新文件上传到特殊容器时可以触发。

我建议您可以使用azure函数blob触发器来实现您的要求。更多详情,可以引用这个article .

在 azure 函数 blob 触发器触发方法中,您还可以绑定(bind) sendgrid发送电子邮件。

更多详细信息,您可以引用以下步骤:

注意:我使用 C# azure 函数作为示例,您也可以使用其他语言。

1.创建blob触发azure函数。

enter image description here

2.创建sendgrid(Link)账户并创建API key 。

enter image description here

3.Create设置创建的azure函数sendgrid outbind。

enter image description here

enter image description here

4.将以下代码添加到azure函数run.csx中。

#r "SendGrid"
using System;
using SendGrid;
using SendGrid.Helpers.Mail;



public static Mail Run(Stream myBlob, string name, TraceWriter log)
{
var message = new Mail
{
Subject = "Azure news"
};

var personalization = new Personalization();
personalization.AddTo(new Email("sendto email address"));

Content content = new Content
{
Type = "text/plain",
Value = name
};
message.AddContent(content);
message.AddPersonalization(personalization);

return message;
}

关于Azure Blob 存储 - 当新文件上传到 Blob 容器中的特定文件夹时设置警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45473066/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com