Go developers have traditionally used Azure Functions Custom Handlers to run Go applications in a serverless environment. This approach allowed developers to build a Go HTTP server and connect it to the Azure Functions host. Although it worked, developers had to manage additional configuration, function metadata, and communication between the host and their application.
Azure Functions now provides native Go worker support. This gives Go developers a more direct programming model with standard Go handlers, typed trigger payloads, and code-based function registration.
The native Go worker removes the need to maintain a separate HTTP server just to communicate with the Functions host. Developers can define functions directly in Go code and let the worker handle communication with the host.
Native Go support is generally available on the Azure Functions Flex Consumption plan. This makes it a practical option for teams that already have Go applications running through Custom Handlers and want to simplify their Azure Functions architecture.
This article explains how Custom Handlers work, what changes with the native Go worker, and how to migrate an existing application without unnecessarily changing its business logic.
Understanding the Custom Handler Architecture
A Custom Handler is an executable or web server that receives HTTP requests from the Azure Functions host. It allows developers to run applications written in languages that do not have a dedicated Azure Functions worker.
Go was commonly used with this approach before native worker support became available.
The architecture contains two main components:
The Azure Functions host receives events from configured triggers.
The custom Go application receives HTTP requests from the host, executes the required function, and returns a response.
For example, when a queue message arrives, the Functions host reads the message and sends an HTTP request to the custom handler. The Go application processes the payload and returns the result.
The application needs to understand the custom handler request format and return the expected response structure.
A typical project looks like this:
GoCustomHandler/
│
├── OrderFunction/
│ └── function.json
│
├── handler.go
├── host.json
├── local.settings.json
└── handler
The function.json file describes the trigger and bindings. The host.json file tells Azure Functions how to start the custom executable.
For example, the custom handler configuration looks like this:
{
"version": "2.0",
"customHandler": {
"description": {
"defaultExecutablePath": "handler"
}
}
}
The application also needs the custom worker runtime setting:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "Custom"
}
}
This configuration works, but it introduces responsibilities that are not necessary when using the native Go worker.
What Changes With the Native Go Worker?
The native Go worker uses a code-first programming model. Instead of starting a separate HTTP server and receiving requests from the host, the application registers functions directly through the Go worker SDK.
The worker communicates with the Functions host through an out-of-process gRPC connection.
This changes how developers define and execute functions.
Area | Custom Handler | Native Go Worker |
|---|
Function registration | function.json | Go code |
Host communication | HTTP requests | Worker gRPC protocol |
Application entry point | Custom executable or server | main.go |
HTTP functions | Custom HTTP server | Standard net/http handlers |
Trigger payloads | Custom handler JSON payload | Supported typed Go values |
Runtime setting | Custom | Go |
Function discovery | Metadata files | Worker-driven indexing |
The native worker also provides dedicated registration methods for supported triggers such as HTTP, Timer, Queue Storage, Cosmos DB, Service Bus, Event Hubs, Event Grid, and Azure SQL.
Some additional capabilities use extension packages and have their own requirements.
The most important benefit is that developers no longer need to maintain the custom handler protocol or manually create function.json files for supported native triggers.
Understanding the Migration Requirements
Before replacing an existing Custom Handler, review the application's hosting environment and supported functionality.
The current native Go worker has the following requirements:
Go 1.24 or later for the core worker.
Go 1.25 or later for extension modules that require it.
Azure Functions Core Tools 4.12.0 or later.
Azure CLI 2.87.0 or later when managing Azure resources through the CLI.
Linux x64 hosting on the Flex Consumption plan.
CGO disabled for the documented deployment target.
Windows hosting and other Azure Functions plans are not currently supported by the native Go worker.
Also review the triggers and bindings used by the existing application. Native support is not identical to every feature available through Custom Handlers. Some input and non-HTTP output bindings are not currently supported.
If an application depends on an unsupported binding, evaluate an alternative implementation before migrating.
Creating a Native Go Worker Project
Start by creating a new Go project.
mkdir GoNativeFunction
cd GoNativeFunction
go mod init example.com/gonativefunction
Install a tagged release of the Azure Functions Go worker:
go get github.com/azure/[email protected]
go mod tidy
Using a tagged release is important because it provides a known version of the worker API. Avoid depending directly on the main development branch for an application that needs predictable builds.
Install Azure Functions Core Tools version 4.12.0 or later and verify the installation:
go version
func --version
az version
A typical project structure looks like this:
GoNativeFunction/
│
├── main.go
├── go.mod
├── go.sum
├── host.json
└── local.settings.json
The main.go file contains the application entry point and function registrations. There is no need to create a separate handler executable configuration or individual function.json files for supported native triggers.
Migrating an HTTP Function
Consider an existing Custom Handler that exposes an HTTP endpoint for retrieving order information.
The old implementation needs to receive the HTTP request from the Functions host and return the appropriate custom handler response.
With the native worker, the same business logic can be implemented using the standard Go HTTP handler signature.
Create main.go:
package main
import (
"fmt"
"net/http"
"github.com/azure/azure-functions-golang-worker/sdk"
"github.com/azure/azure-functions-golang-worker/worker"
)
func getOrder(
w http.ResponseWriter,
r *http.Request,
) {
orderID := r.URL.Query().Get("orderId")
if orderID == "" {
http.Error(
w,
"Order ID is required",
http.StatusBadRequest,
)
return
}
fmt.Fprintf(
w,
"Order %s retrieved successfully",
orderID,
)
}
func main() {
app := sdk.FunctionApp()
app.HTTP(
"getOrder",
getOrder,
sdk.WithMethods("GET"),
sdk.WithAuth("function"),
)
worker.Start(app)
}
The application registers an HTTP-triggered function named getOrder.
The handler receives the standard http.ResponseWriter and *http.Request parameters. It can use familiar Go features such as request headers, query parameters, request context, and response writers.
The SDK takes care of registering the function with the Functions host.
For example, the endpoint can be called with:
curl "http://localhost:7071/api/getOrder?orderId=ORD-1001"
Because the function uses function-level authorization, a deployed request must also provide the required function key.
The important migration point is that the business logic does not need to understand the old custom handler request payload. It works directly with standard Go HTTP types.
Migrating Queue-Triggered Functions
The native worker also provides dedicated registration methods for supported event triggers.
Consider an existing Custom Handler that processes messages from Azure Queue Storage.
The old application receives the queue message through the custom handler payload. The native worker can register the queue trigger directly and pass the message to the Go handler.
For example:
package main
import (
"context"
"log"
"github.com/azure/azure-functions-golang-worker/sdk"
"github.com/azure/azure-functions-golang-worker/worker"
)
func processOrder(
ctx context.Context,
message []byte,
) error {
log.Printf(
"Received order message: %s",
string(message),
)
// Add order validation and processing logic here.
return nil
}
func main() {
app := sdk.FunctionApp()
app.Queue(
"processOrder",
processOrder,
sdk.WithQueueName("orders"),
sdk.WithConnection("AzureWebJobsStorage"),
)
worker.Start(app)
}
The queue handler receives the message as a byte slice. The application can deserialize it into a Go structure using encoding/json.
For example:
type Order struct {
OrderID string `json:"orderId"`
Amount int `json:"amount"`
}
The handler can then validate the order and call the existing business services.
This approach removes the need to manually extract the queue message from the custom handler's Data and Metadata fields.
However, the native worker and Custom Handler do not necessarily expose identical binding behavior. Review the supported trigger signatures and configuration options before replacing each function.
Updating the Host Configuration
The old Custom Handler configuration contains a customHandler section that points to the executable.
The native Go worker does not use that section.
A basic host.json file can remain simple:
{
"version": "2.0"
}
Update local.settings.json to use the native Go worker runtime:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "go"
}
}
The storage setting assumes that Azurite is running locally. Use the appropriate connection configuration for the triggers and services used by the application.
Also remove the old customHandler configuration and stop relying on the Custom Handler executable.
The new project should use the worker SDK and its code-first registration model.
Moving Existing Business Logic
A common migration mistake is rewriting the entire application when only the function registration and communication layer need to change.
In most projects, the business logic can remain in separate Go packages.
For example, an application might already have this structure:
internal/
│
├── orders/
│ ├── service.go
│ └── models.go
│
├── payments/
│ └── service.go
│
└── inventory/
└── service.go
Keep these packages independent of Azure Functions.
The new worker handler should call the existing services rather than moving database queries, validation rules, and payment operations directly into main.go.
This separation makes the application easier to test and allows the same business logic to be reused by HTTP functions, queue triggers, scheduled jobs, or other Go applications.
Also review error handling during migration. With the native worker, handlers should return errors according to the supported trigger handler signature. Do not assume that an HTTP status code or a custom handler response payload has the same meaning for a queue or timer trigger.
Building and Deploying the Native Go Application
Native Go applications run on Linux x64 in Flex Consumption. The documented build target uses CGO disabled.
For a local Linux x64 build, the configuration can be set as follows:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o app .
For Azure deployment, use the supported Azure Functions Core Tools packaging and deployment workflow for the native Go worker.
Create or select a Linux Flex Consumption Function App configured for Go. Make sure the required storage account and application settings are available.
Publish the application using Core Tools:
func azure functionapp publish <FUNCTION_APP_NAME>
After deployment, verify that the Functions host discovers the registered functions and that the expected triggers execute successfully.
Do not simply copy the old Custom Handler executable into the new application directory. The native worker uses a different application startup and function registration model.
Testing the Migration
Test the application before switching production traffic.
For HTTP functions, verify the route, HTTP methods, authorization settings, response status codes, and request validation.
For queue-triggered functions, verify that messages are received, processed, and handled correctly when failures occur.
Also test the following areas:
Function discovery and startup.
Application settings and connection strings.
Trigger configuration and message processing.
Retry behavior and failed executions.
Logging and monitoring.
Concurrency and scaling behavior.
Any external service or database integrations.
Use a separate Function App for validation whenever possible. This allows the old Custom Handler and the new native worker to run independently during migration.
Once the new application passes testing, move traffic or update the event source configuration using a controlled deployment process.
Common Migration Problems
Functions Are Not Discovered
If the Functions host does not discover the Go functions, verify that the application uses the native worker SDK and that every supported function is registered before worker.Start is called.
Also check the Core Tools version and application startup logs.
Runtime Configuration Is Incorrect
An application that still uses FUNCTIONS_WORKER_RUNTIME=Custom is configured for the old Custom Handler model.
Change the setting to go for the native worker and remove the old customHandler section from host.json.
Deployment Fails
Verify that the target Function App uses Linux Flex Consumption and that the application is built for Linux x64.
For the documented packaging workflow, use CGO_ENABLED=0. Native libraries that require CGO may need to be replaced or handled through a supported alternative.
A Binding Is Not Supported
Do not assume that every Custom Handler binding has a direct native Go equivalent.
Check the current Go worker trigger and binding support documentation. If a required feature is not available, consider using an Azure SDK client directly from the Go application or retaining a separate application component for that workload.
Advantages and Limitations
The native Go worker offers several advantages:
Removes the need to maintain a separate custom HTTP server.
Registers supported functions directly in Go code.
Uses familiar net/http handlers for HTTP functions.
Provides typed trigger payloads for supported triggers.
Reduces manual function metadata management.
Integrates with the Azure Functions worker and trigger ecosystem.
However, there are limitations to consider:
Native Go hosting currently targets Linux Flex Consumption.
Go applications must target Linux x64 with CGO disabled for the documented deployment model.
Some input and non-HTTP output bindings are not supported.
The native worker does not provide an automatic migration of existing Custom Handler projects.
Applications using unsupported triggers or bindings need additional design work.
Summary
Replacing an Azure Functions Custom Handler with the native Go worker simplifies how Go applications integrate with Azure Functions.
The old model required a separate HTTP server, custom handler configuration, and function.json files. The native worker provides a code-first approach using standard Go handlers, dedicated trigger registration methods, and worker-managed function discovery.
The most important migration tasks are reviewing trigger compatibility, moving function registration into Go code, updating the runtime configuration, and deploying to the supported Flex Consumption environment.
Keep existing business logic separate from the worker integration, test each trigger independently, and deploy the new application alongside the old one before switching production traffic. This approach reduces migration risk while making the application easier to maintain and extend.
Join the conversation! Your thoughts help the community grow.