Integrate code into an Azure Functions app

 

Host web application under Microsoft Azure, integrate Part 4 Code into an Azure Functions app

The basic framework for the Azure Functions app stands. In the fourth part of this tutorial we roll out the actual function code for our serverless web application, which should ultimately ensure the calculation of our thumbnails.

Companies on the topic

The Deployment Center of Azure Functions provides some options for code integration, for example by connecting an external or local Git repository.The Deployment Center of Azure Functions provides some options for code integration, for example by connecting an external or local Git repository.

(Image: Drilling / Microsoft)

Just like web apps, Functions Apps allow you to deploy code from templates, manually using the local IDE of your choice or a CI/CD pipeline.Just like web apps, Functions Apps allow you to deploy code from templates, manually using the local IDE of your choice or a CI/CD pipeline.

(Image: Drilling / Microsoft)

After having laid the foundations for our Image Resizer in the previous four parts, we are now ready to provide the actual function code for our Functions app. The example function used in the following for the actual resizing is available in C# on GitHub. The “pull” and provision of the code can be realized e.g. via the command line with the following command:

az functionapp deployment source config --name $functionapp --resource-group $resourceGroupName --branch master --manual-integration --repo-url https://github.com/Azure-Samples/function-image-upload-resize

You can also add the previously cloned code from GitHub manually from VS Code, Visual Studio or any other editor in the Functions app in the “Functions / Functions” section by clicking on “Develop locally”.

The Deployment Center provides some options for code integration, for example by connecting an external or local Git repository.The Deployment Center provides some options for code integration, for example by connecting an external or local Git repository.

(Image: Drilling / Microsoft)

The code can also be uploaded via an FTP connection.The code can also be uploaded via an FTP connection.

(Image: Drilling / Microsoft)

An alternative is to create your own CI / CD pipeline in the “Deployment Center” menu. You can choose between connecting a local Git repository, which you can clone for this purpose in the cloud shell of GitHub, for example, or uploading the function code via FTP. Instantly usable FTP login data and the FTP endpoint are automatically created in the “App Credentials” dialog; however, if you like, you can also create individual login data under “User Credentials”.

Making the service reactive

Now only our event trigger is missing, the image calculation should be done automatically as soon as a new image is uploaded. Here we need an event subscription for the Azure service EventGrid.

If you compare all messaging services in Azure, i.e. Event Grid, Event Hubs, Service Bus and queues in a storage account, each of the services is designed for specific scenarios. However, the messaging outstaffing services often complement each other and can be used together; however, Event Grid is primarily suitable for reactive programming.

Specifically, this is an event backplane that enables event-driven, reactive programming. Similar to Simple Notification Service from AWS (SNS), a publisher/subscriber model is used, whereby publishers output events but have no influence on which events are handled.

The subscribers decide for themselves, so to speak, which events they want to cover. The event subscription thus specifies which events generated by the provider are to be sent to a specific endpoint. In our case, the endpoint is made available by Azure Functions. We will look at how this works in the last part.

(ID:46866558)

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