简体   繁体   中英

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. 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. 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? If not from the code, how can I do this?

I think you should try EventGrid for your requirement. 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.

在此处输入图片说明

You can filter which event you want to listen.

在此处输入图片说明

Then you can route your message to the appropriate endpoint (Azure Function Or Queue)

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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