简体   繁体   English

在使用 C# 代码创建 Blob 容器时创建和部署 Azure 函数

[英]Create and Deploy an Azure Function at Blob Container Creation in C# Code

I have a (.net core C#) API to handle image upload, retrieve, delete, etc. Images are uploaded to blob containers, that are dynamically created from the code, with a name given with the POST request when uploading an image.我有一个(.net core C#)API 来处理图像上传、检索、删除等。图像被上传到 blob 容器,这些容器是从代码动态创建的,在上传图像时使用 POST 请求指定的名称。 There is also a blob trigger function deployed in Azure to create resized low-quality image for each image uploaded for a given blob container. Azure 中还部署了一个 blob 触发器函数,可为给定 blob 容器上传的每个图像创建调整大小的低质量图像。 There is a need to duplicate this image resize function app for each new container that is created.需要为创建的每个新容器复制此图像调整大小功能应用程序。 IF duplicated, I need to bind the new container names as the source and destination containers of the new instance of the image-resize function app, AND deploy it in the same resource group as the first function app.如果重复,我需要将新容器名称绑定为图像调整大小函数应用程序的新实例的源和目标容器,并将其部署在与第一个函数应用程序相同的资源组中。

Is there any way I can achieve all of this from the C# code?有什么办法可以从 C# 代码中实现所有这些吗? If not from the code, how can I do this?如果不是来自代码,我该怎么做?

I think you should try EventGrid for your requirement.我认为您应该根据您的要求尝试EventGrid Below image give you a high idea you can change some component according to your business requirement.下图为您提供了一个很好的想法,您可以根据您的业务需求更改一些组件。

在此处输入图片说明

EventGrid Topic built-in with storage account so you don't need to create separately. EventGrid Topic 内置存储帐户,因此您无需单独创建。

在此处输入图片说明

You can filter which event you want to listen.您可以过滤要收听的事件。

在此处输入图片说明

Then you can route your message to the appropriate endpoint (Azure Function Or Queue)然后,您可以将消息路由到适当的端点(Azure 函数或队列)

在此处输入图片说明

If you're storing resize images in the same storage account you will get an event for those images, You can put some logic to filter those image from your Function.如果您将调整大小的图像存储在同一个存储帐户中,您将获得这些图像的事件,您可以放置​​一些逻辑来从您的函数中过滤这些图像。

You will not face any latency issue with EventGrid while Blob trigger has some latency issue. EventGrid 不会遇到任何延迟问题,而 Blob 触发器有一些延迟问题。

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

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