tetsis / function-image-upload-resize

Function app that subscribe Event Grid, resize image and upload to Azure Storage.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

function-image-upload-resize

Architecture

           |-Blob Storage-------|                    |-Event Grid-|
- Upload ->| "images" container |- Created/Deleted ->| topic      |--
           |--------------------|                    |------------| |
                                                                    |
                                                          Subscribe |
                                                                    |
|-Blob Storage-----------|                  |-Azure Functions-|     |
| "thumbnails" container |<- Upload/Delete -| funciton app    |<-----
|------------------------|                  |-----------------|

Prerequisites

  • Azure subscription
  • Resource group
  • Storage account
    • Container for original image (e.g. "images")
    • Container for thumbnail (e.g. "thumbnails")
    • These two containers can be the same or different storage accounts.
  • Function app
    • .NET6

How to deploy

Execute the following commands using Azure CLI or Cloud Shell.

  • Specify the name for resources.
resourceGroupName="myResourceGroup"
blobStorageAccount="myStorageAccountForThumbnails"
functionapp="myFunctionapp"
  • Configure the funciton app
storageConnectionString=$(az storage account show-connection-string --resource-group $resourceGroupName --name $blobStorageAccount --query connectionString --output tsv)
az functionapp config appsettings set --name $functionapp --resource-group $resourceGroupName --settings AzureWebJobsStorage=$storageConnectionString THUMBNAIL_CONTAINER_NAME=thumbnails THUMBNAIL_WIDTH=100
  • Deploy the function code
az functionapp deployment source config --name $functionapp --resource-group $resourceGroupName --branch main --manual-integration --repo-url https://github.com/tetsis/function-image-upload-resize
Event Function
Blob Created Thumbnail
Blob Deleted DeleteThumbnail

References

About

Function app that subscribe Event Grid, resize image and upload to Azure Storage.

License:MIT License


Languages

Language:C# 100.0%