Reactive Azure Functions App with EventGrid

 

Host Web application under Microsoft Azure, Part 4 Reactive Azure Functions App with EventGrid

Our serverless Functions app, which can calculate thumbnails from images in a source memory blob in a target memory blob, is already functional. Finally, we want to automate the process with a Trigger in EventGrid.

Companies on the topic

The function codeThe function code “Thumbnail” manually uploaded from GitHub can also be edited afterwards.

(Image: Drilling / Microsoft)

The function codeThe function code “Thumbnail” manually uploaded from GitHub must be connected to an event trigger.

(Image: Drilling / Microsoft)

To automate thumbnail calculation with our Azure Functions app, we create an event subscription. This specifies which events generated by the provider are to be sent to a specific endpoint. In this case, the endpoint is made available by our Azure function.

In the following steps, we create an event subscription that sends notifications to our feature in the Azure portal. To do this, we now navigate to our Functions app in the Azure portal and there to our thumbnail function in the “Functions”section of the main menu.

TheThe “Thumbnail” function code uploaded manually from GitHub can be viewed and edited in the “Program and Test” menu.

(Image: Drilling / Microsoft)

If we follow the link “Thumbnail”, we can see or edit the function code by selecting the menu” Program and test “and configure the desired” triggers “in the menu” Integration”.

A trigger (here Event Grid Trigger) serves as a trigger for our function code. However, the selected trigger can be adjusted and edited at any time.A trigger (here Event Grid Trigger) outsourcing serves as a trigger for our function code. However, the selected trigger can be adjusted and edited at any time.

(Image: Drilling / Microsoft)

Here we click on the link ” EventGrid Trigger “and then click on the link” Create Event Grid subscription “in the pop-up menu”Edit trigger” in the upper right corner.

To Create an Event subscription for the Event themeTo Create an Event subscription for the Event theme “azditeventgridtopic”.

(Image: Drilling / Microsoft)

On the Create Event Subscription page, all we have to do is assign a name for the subscription and select the Event Grid Schema entry for the Event Schema. Then, in the section “Topic Details”, we select the desired storage account with the image container and assign a name for the EventGrid topic. In the Event Types section, we apply the default setting, which includes the two event types “Blob Created” and “Blob Deleted”, followed by a click on “Create”.

The newly created EventGrid subscription is of course also visible in the Eventsubscription console.The newly created EventGrid subscription is of course also visible in the Eventsubscription console.

(Image: Drilling / Microsoft)

A counter-check confirms the successful creation of the subscription. To do this, search for “Event subscriptions” in the portal and filter the display by “Topic type” (Storage Accounts) and “Location”. Also here should now appear the end point “Thumbnails”. Alternatively, you could have created the subscription from here.

Test our image resizer in the Azure Web app.Test our image resizer in the Azure Web app.

(Image: Drilling / Microsoft)

Now we can test the finished serverless app: for this we connect again with our photo upload web app from part 1 and select an image file to upload. This also works optionally via drag & amp; drop. After the” disappearance “of the uploaded image, a copy of the uploaded image is displayed under” Generated Thumnails”. So the size of this image was changed by the function, added to the thumnails container and downloaded from the webclient.

The automatically and event-based image ends up as a blob in the destination container.The automatically and event-based image ends up as a blob in the destination container.

(Image: Drilling / Microsoft)

A counter-check directly into the thumbnail container in the storage account also confirms the success.

(ID:46903633)

Ready to see us in action:

More To Explore

IWanta.tech
Logo
Enable registration in settings - general
Have any project in mind?

Contact us:

small_c_popup.png