繁体   English   中英

通过电子邮件发送 Azure blob 存储上的文件

[英]Emailing a file on an Azure blob storage

每周一,定时器触发的 Function 应用程序会将一个文件添加到 Azure blob 存储中。 我想知道是否有办法通过 email 将其作为附件发送给人们。 发件人 email 将是我的组织,而不是 GMail 或 Outlook 或任何东西。 收件人也将来自我的组织。

所有 Function 应用程序代码都是用 Python 编写的,所以它是一个 Linux 环境,它使用的是消费计划。 我知道我无法进行 Sendgrid 绑定,因为它不支持 Python(在撰写本文时)。

我浏览过有关使用 MIMEMultipart 发送电子邮件的文章,但它所寻求的“附件”位于本地。 我感兴趣的文件在 Azure 存储帐户中。

我环顾四周,但找不到任何支持它的东西。 由于我在 Python 上执行此操作,因此我更加茫然。

拜托,你能帮帮我吗?

长话短说:我有一个关于 Azure 存储帐户并使用 Python 的文件,我想将其通过电子邮件发送给人们。

您可以使用 blob 触发器创建新的 Azure Function。

这是一个关于它的示例:

def main(myblob: func.InputStream):
    logging.info(f"Python blob trigger function processed blob \n"
                 f"Name: {myblob.name}\n"
                 f"Blob Size: {myblob.length} bytes")

    img_data = myblob.read()

    #Logic to send the email in here

    try:
    except Exception as e:
        print('Error:')
        print(e)

来源: https://github.com/yokawasa/azure-functions-python-samples/tree/master/v2functions/blob-trigger-cosmosdb-out-binding

Another option, which I believe is easier, just use Logic Apps with Azure Storage Connector and your favorite tool to send the email (Sendgrid, outlook, gmail, etc)

https://docs.microsoft.com/bs-latn-ba/azure//////connectors/connectors-create-api-azureblobstorage

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM