DEV Community

Cover image for How to Implement Azure Functions in any Language with Custom Handlers
Digital Craft Workshop
Digital Craft Workshop

Posted on • Originally published at Medium

How to Implement Azure Functions in any Language with Custom Handlers

How to Implement Azure Functions in any Language with Custom Handlers

Introduction of Custom Handlers with Demo using Go Language.

How to Implement Azure Functions in any Language with Custom Handlers cover image

Azure Functions with Go Language

Introduction

Every Azure Function has its handler. Azure Functions supports handler implementations in many different languages but they may not provide a native implementation in your favorite language. That is where Custom Handlers comes at the scene.

The language of your choice must support HTTP communication because Custom Handler is a web server that receives events from Functions Host modified into HTTP requests with JSON payloads.

Illustration

Communication Diagram

Functions Host is a bunch of JSON configuration files where you will define which trigger and bindings you want to use and of course the path to the executable file, which is our Custom Handler (Web Server).

Once the Trigger activates by event, the Functions Host sends a request payload to the Web Server. The payload can hold trigger and input binding data.

The Web Server invokes the function and possibly returns a response payload. A response payload can be used for output binding.

Demo

The source code can be found on my GitHub.

Things you Need

Create Project

Illustration

Location of Create New Project Button
  1. Click on the button highlighted in the image to create a new project.
  2. You will be asked to choose basic settings. Select Custom language, HTTP TriggerHttpExample as a name of the function, and Anonymous authorization level to define Function Host.

Create a Handler

  1. Create a file in the root folder and save it as handler.go.
  2. Copy/Paste this code into the file.

The function helloHandler is printing a simple message as an HTTP response. The form of the message depends on the value of nameparameter in the HTTP request.

If the value name is set, the response will be:

Hello, {name}. This HTTP triggered function executed successfully.
Enter fullscreen mode Exit fullscreen mode

If the value name is NOT set, the response will look like this:

This HTTP triggered function executed successfully. Pass a name in the query string for a personalized response.
Enter fullscreen mode Exit fullscreen mode

3. Open a command line or PowerShell and compile Custom Handler into an executable file named handler.exe by using this command (installed Go):

go build handler.go
Enter fullscreen mode Exit fullscreen mode

Modify host.json

Now you need to specify the file path for customHandler:defaulteExecutablePath property in host.json. If you created the *.exe file in the root folder, you can set the value to handler.

You also need to set the value of customHandler:eneableForwardingHttpRequest to true.

On a side note — if you like getting your tooling set up properly like this, I put together a short free email series, The Claude Code Memory Starter, on giving AI coding agents a persistent memory.

Run the function

  1. Open a command line or PowerShell again and run this command (installed Azure Function Core Tools) in the root folder:
func start
Enter fullscreen mode Exit fullscreen mode

2. Navigate to the following URL to execute the function:

[http://localhost:7071/api/HttpExample?name=medium](http://localhost:7071/api/HttpExample?name=medium)

Illustration

If you get a similar response as me, you were successful.

3. You can also take a look into the console and see if your function was executed.

Illustration

Summary

We found out what Custom Handlers of Azure Functions are, how they work, and how we can easily implement them with Go language. As a next step, I would recommend that you should try to publish function into the Azure.

If you like the article, give it a few claps. Thank you for your time.

If a topic like this is your kind of thing, you might also enjoy my free email series The Claude Code Memory Starter — a few short lessons on giving AI coding tools a memory that sticks.

Sources

Further Reading

How to Create a Free Azure Account Step by Step

Guide for creating a free Azure account. What services you can use for free? What is Directory or subscription and what…levelup.gitconnected.com

Introduction to Cloud Computing

Cloud computing is the present and future of software utilization, development and hosting. Let me introduce you its…levelup.gitconnected.com

Understanding the Azure Resource Groups and Azure Resources

Also with Guide How to Create your First Azure Resource Group and Add your Azure Resource Into it.danielrusnok.medium.com

How to Choose the Azure Region

What you should consider before choosing Azure Region? How Microsoft geographically divide datacentres position to…danielrusnok.medium.com

Illustration

 Related Reading

Top comments (0)