Help us shape the future of Go! Take the 2026 Go Developer Survey

azurefunctions

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 34 Imported by: 0

README

Azure Functions

Parity grade: B · SDK azure-sdk-for-go/sdk/resourcemanager/appservice/armappservice/v6@v6.0.0 · last audited 2026-10-25 (959104c86)

Coverage

Metric Value
PARITY entries audited 6 (6 ok)
Feature families 6 (6 ok)
Known gaps 12
Deferred items 0
Resource leaks ok
Known gaps
  • Non-HTTP triggers (timer, queue, blob, Service Bus, Event Hubs) are run by the real host but are unverified here: containers cannot reach the emulator's Storage, Service Bus or Event Hubs ports (no host-gateway or extra-hosts support in pkgs/container) and a timer needs a reachable AzureWebJobsStorage.
  • Remote build is not implemented: Python and Node dependencies must be packed into the zip (SCM_DO_BUILD_DURING_DEPLOYMENT is ignored).
  • WEBSITE_RUN_FROM_PACKAGE with a URL is ignored; the deployed zip is always used.
  • The listener is plain HTTP; Kudu only supports zipdeploy, publish?type=zip, deployments and the site zip download (no vfs, command, logstream or webjobs APIs).
  • Windows function apps and Functions runtime versions other than ~4 run in the same Linux v4 images.
  • Not implemented: DELETE sites/{name}/functions/{fn}, deployment slots, functions/admin/token, syncfunctiontriggers, Flex Consumption (functionAppConfig), app-level managed identity, VNet integration, custom domains and certificates, easy auth (authsettings are stored only).
  • Deployment slots (sites/slots CRUD, slotConfigNames behaviour, swap with preview, complete and reset) are not implemented; slot-specific hostnames -. are not routed.
  • Web apps: private registries (DOCKER_REGISTRY_SERVER_* credentials, ACR managed identity) are not supported, so only images the local runtime can pull anonymously start; EXPOSE auto-detection is not done (DOCKER apps use WEBSITES_PORT, PORT or 80).
  • Web apps: no remote build (Oryx), so Node and Python dependencies must be inside the zip; Python apps need appCommandLine or an app.py/main.py entry (no gunicorn auto-detection); Tomcat, JBoss, Ruby and Go stacks, Windows web apps, multi-container (sitecontainers) and docker-compose apps are rejected with 400.
  • Web apps: alwaysOn does not keep a container warm (hosts are never reaped anyway) and is not validated against the plan tier; an unhealthy running instance is not evicted or restarted after startup.
  • Hosts are never reaped while idle; a stopped, redeployed or deleted app, or an emulator shutdown, removes them.
  • No dashboard page.

More

Documentation

Overview

Package azurefunctions emulates Azure Functions and Linux App Service web apps. Function apps' HTTP-triggered functions run in the official Azure Functions host containers behind <app>.<domain>/api/<function>, with the host's own authLevel key enforcement; web apps run their stack or custom image behind <app>.<domain>. Both get the Kudu zip-deploy API on <app>.scm.<domain>. Apps are created through the ARM Microsoft.Web provider, which shares their settings, keys and packages. See PARITY.md.

Index

Constants

View Source
const (
	// KeyTypeFunction and KeyTypeSystem are the host key collections ARM addresses as host/default/{keyType}.
	KeyTypeFunction = "functionKeys"
	// KeyTypeSystem is the host key collection extensions use.
	KeyTypeSystem = "systemKeys"
)
View Source
const (
	// DefaultPort is the function-app and Kudu listener's default TCP port.
	DefaultPort = 10012
	// DefaultDomain is the default hostname suffix: <app>.<domain> serves functions, <app>.scm.<domain> Kudu.
	DefaultDomain = "azurewebsites.localhost"
	// EngineAuto runs function apps in the container runtime when one is reachable.
	EngineAuto = "auto"
	// EngineNone never starts containers: apps deploy but invocations return 503.
	EngineNone = "none"
	// DefaultStartupTimeout bounds how long a function host container may take to accept connections.
	DefaultStartupTimeout = 5 * time.Minute
)

Variables

View Source
var (
	// ErrNilAppContext is returned when Init is called with a nil AppContext.
	ErrNilAppContext = errors.New("azurefunctions: nil app context")
	// ErrAppNotFound is returned for an unknown function app.
	ErrAppNotFound = errors.New("azurefunctions: function app not found")
	// ErrFunctionNotFound is returned for an unknown function.
	ErrFunctionNotFound = errors.New("azurefunctions: function not found")
	// ErrKeyNotFound is returned for an unknown host or function key.
	ErrKeyNotFound = errors.New("azurefunctions: key not found")
	// ErrInvalidKeyType is returned for a host key type other than functionKeys or systemKeys.
	ErrInvalidKeyType = errors.New("azurefunctions: key type must be functionKeys or systemKeys")
	// ErrInvalidPackage is returned when a deployment is not a readable zip archive.
	ErrInvalidPackage = errors.New("azurefunctions: deployment package is not a valid zip archive")
)

Functions

func ValidateConfig

func ValidateConfig(cfg AppConfig) error

ValidateConfig reports whether the emulator can run the app's stack; function apps are validated at start.

Types

type AppConfig

type AppConfig struct {
	Kind            string
	LinuxFx         string
	AppCommandLine  string
	HealthCheckPath string
}

AppConfig is what ARM supplies about a site: its kind and the runtime stack it selected.

type AppInfo

type AppInfo struct {
	Created    time.Time
	LastDeploy time.Time
	HostName   string
	SCMHost    string
	Image      string
	Worker     string
	Failure    string
	Stopped    bool
	Deployed   bool
}

AppInfo is the data plane's view of an app.

type ConfigProvider

type ConfigProvider interface {
	GetAzureFunctionsSettings() Settings
}

ConfigProvider extracts the Azure Functions settings from the AppContext config.

type Deployment

type Deployment struct {
	Received  time.Time `json:"received"`
	Finished  time.Time `json:"finished"`
	ID        string    `json:"id"`
	Deployer  string    `json:"deployer"`
	Message   string    `json:"message"`
	Succeeded bool      `json:"succeeded"`
}

Deployment is one Kudu deployment record.

type FunctionDef

type FunctionDef struct {
	Config map[string]any
	Name   string
}

FunctionDef is one function discovered from a deployed package's function.json files.

type FunctionInfo

type FunctionInfo struct {
	Config     map[string]any
	Name       string
	Language   string
	InvokeURL  string
	IsDisabled bool
}

FunctionInfo describes one function of an app.

type Handler

type Handler struct {
	Backend *InMemoryBackend

	Settings Settings
	Port     int
	// contains filtered or unexported fields
}

Handler owns the function-app listener.

func NewHandler

func NewHandler(backend *InMemoryBackend, settings Settings) *Handler

NewHandler returns a Handler over backend.

func (*Handler) ExtractOperation

func (h *Handler) ExtractOperation(*echo.Context) string

ExtractOperation implements service.Service.

func (*Handler) ExtractResource

func (h *Handler) ExtractResource(*echo.Context) string

ExtractResource implements service.Service.

func (*Handler) GetSupportedOperations

func (h *Handler) GetSupportedOperations() []string

GetSupportedOperations implements service.Service.

func (*Handler) Handler

func (h *Handler) Handler() echo.HandlerFunc

Handler returns a 404 handler; the real API is on the dedicated port.

func (*Handler) MatchPriority

func (h *Handler) MatchPriority() int

MatchPriority implements service.Registerable.

func (*Handler) Name

func (h *Handler) Name() string

Name implements service.Service.

func (*Handler) Reset

func (h *Handler) Reset()

Reset implements service.Resettable.

func (*Handler) Restore

func (h *Handler) Restore(ctx context.Context, data []byte) error

Restore implements persistence.Persistable by delegating to the backend.

func (*Handler) RouteMatcher

func (h *Handler) RouteMatcher() service.Matcher

RouteMatcher never matches: function apps listen on their own port.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves the dedicated listener.

func (*Handler) Shutdown

func (h *Handler) Shutdown(ctx context.Context)

Shutdown implements service.Shutdowner.

func (*Handler) Snapshot

func (h *Handler) Snapshot(ctx context.Context) []byte

Snapshot implements persistence.Persistable by delegating to the backend.

func (*Handler) StartWorker

func (h *Handler) StartWorker(ctx context.Context) error

StartWorker binds the listener synchronously so a port conflict is returned to the caller.

type HostKeys

type HostKeys struct {
	FunctionKeys map[string]string
	SystemKeys   map[string]string
	MasterKey    string
}

HostKeys are an app's host-level keys.

type InMemoryBackend

type InMemoryBackend struct {
	// contains filtered or unexported fields
}

InMemoryBackend holds all function apps under one lock.

func NewInMemoryBackend

func NewInMemoryBackend() *InMemoryBackend

NewInMemoryBackend creates an empty backend with no container runtime.

func (*InMemoryBackend) App

func (b *InMemoryBackend) App(name string) (AppInfo, bool)

App returns the app's data-plane view.

func (*InMemoryBackend) Close

func (b *InMemoryBackend) Close()

Close stops every host and runs the onClose hook.

func (*InMemoryBackend) Configure

func (b *InMemoryBackend) Configure(s Settings)

Configure applies the listener-facing settings.

func (*InMemoryBackend) DeleteApp

func (b *InMemoryBackend) DeleteApp(name string)

DeleteApp stops and removes the app.

func (*InMemoryBackend) DeleteFunctionKey

func (b *InMemoryBackend) DeleteFunctionKey(name, fn, keyName string) error

DeleteFunctionKey removes a function key.

func (*InMemoryBackend) DeleteHostKey

func (b *InMemoryBackend) DeleteHostKey(name, keyType, keyName string) error

DeleteHostKey removes a host key.

func (*InMemoryBackend) Deploy

func (b *InMemoryBackend) Deploy(name string, zipData []byte, deployer, message string) (Deployment, error)

Deploy stores a zip package as the app's site content and records the deployment.

func (*InMemoryBackend) Deployments

func (b *InMemoryBackend) Deployments(name string) ([]Deployment, error)

Deployments returns the app's deployments, newest last.

func (*InMemoryBackend) Function

func (b *InMemoryBackend) Function(ctx context.Context, name, fn string) (FunctionInfo, error)

Function returns one function of the app.

func (*InMemoryBackend) FunctionKeys

func (b *InMemoryBackend) FunctionKeys(name, fn string) (map[string]string, error)

FunctionKeys returns a function's keys, creating its default key on first use as Azure does.

func (*InMemoryBackend) Functions

func (b *InMemoryBackend) Functions(ctx context.Context, name string) ([]FunctionInfo, error)

Functions lists the app's functions. With a container runtime they come from the running host's admin API, which also sees code-first (no function.json) functions; without one, from the deployed package's function.json files.

func (*InMemoryBackend) HostKeys

func (b *InMemoryBackend) HostKeys(name string) (HostKeys, error)

HostKeys returns the app's master, function and system keys.

func (*InMemoryBackend) HostName

func (b *InMemoryBackend) HostName(name string) string

HostName is the default hostname apps are served under, including the listener port.

func (*InMemoryBackend) Names

func (b *InMemoryBackend) Names() []string

Names lists app names in order.

func (*InMemoryBackend) Package

func (b *InMemoryBackend) Package(name string) []byte

Package returns the deployed zip, or nil.

func (*InMemoryBackend) PublishingCredentials

func (b *InMemoryBackend) PublishingCredentials(name string) (string, string, string, error)

PublishingCredentials returns the Kudu user name, password and base URL.

func (*InMemoryBackend) PutApp

func (b *InMemoryBackend) PutApp(name string, cfg AppConfig) AppInfo

PutApp creates the app or updates its kind and stack, keeping settings, keys and package.

func (*InMemoryBackend) Reset

func (b *InMemoryBackend) Reset()

Reset stops every host and clears all apps.

func (*InMemoryBackend) Restart

func (b *InMemoryBackend) Restart(name string) error

Restart discards the running host; the next request starts a fresh one.

func (*InMemoryBackend) Restore

func (b *InMemoryBackend) Restore(ctx context.Context, data []byte) error

Restore loads a snapshot, replacing every app; hosts start again on first use.

func (*InMemoryBackend) ServeHTTP

func (b *InMemoryBackend) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes a request to an app's function host or its Kudu API.

func (*InMemoryBackend) SetFunctionKey

func (b *InMemoryBackend) SetFunctionKey(name, fn, keyName, value string) (string, error)

SetFunctionKey creates or replaces a function key; an empty value generates one.

func (*InMemoryBackend) SetHostKey

func (b *InMemoryBackend) SetHostKey(name, keyType, keyName, value string) (string, error)

SetHostKey creates or replaces a host key; an empty value generates one. It returns the stored value.

func (*InMemoryBackend) SetOnClose

func (b *InMemoryBackend) SetOnClose(fn func())

SetOnClose registers a hook run by Close after every container is stopped.

func (*InMemoryBackend) SetPortPool

func (b *InMemoryBackend) SetPortPool(p PortPool)

SetPortPool wires the host port source for published containers.

func (*InMemoryBackend) SetRuntime

func (b *InMemoryBackend) SetRuntime(fn func() (Runner, error))

SetRuntime wires the container runtime source; nil disables function hosts.

func (*InMemoryBackend) SetSettings

func (b *InMemoryBackend) SetSettings(name string, settings map[string]string) error

SetSettings replaces the app's application settings; a running host restarts on its next request.

func (*InMemoryBackend) SetStopped

func (b *InMemoryBackend) SetStopped(name string, stopped bool) error

SetStopped starts (false) or stops (true) the app.

func (*InMemoryBackend) Settings

func (b *InMemoryBackend) Settings(name string) (map[string]string, error)

Settings returns a copy of the app's application settings.

func (*InMemoryBackend) Snapshot

func (b *InMemoryBackend) Snapshot(ctx context.Context) []byte

Snapshot serialises apps, settings, keys, deployments and package bytes; running hosts are not part of it.

type PortPool

type PortPool = gcpserve.PortPool

PortPool hands out host ports for published containers.

type Provider

type Provider struct{}

Provider implements service.Provider for Azure Functions.

func (*Provider) Init

Init builds the backend and handler; the port is bound by Handler.StartWorker.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the service provider name.

type Runner

type Runner = gcpserve.Runner

Runner is the slice of the container runtime that function apps need.

type Settings

type Settings struct {
	Engine string `` //nolint:lll // config struct tags are intentionally verbose
	/* 229-byte string literal not displayed */
	Domain string `` //nolint:lll // config struct tags are intentionally verbose
	/* 300-byte string literal not displayed */
	Port int `` //nolint:lll // config struct tags are intentionally verbose
	/* 256-byte string literal not displayed */
	StartupTimeout time.Duration `` //nolint:lll // config struct tags are intentionally verbose
	/* 226-byte string literal not displayed */
}

Settings is the Kong-embedded configuration of the Azure Functions emulator.

func DefaultSettings

func DefaultSettings() Settings

DefaultSettings returns the settings used when no ConfigProvider is available.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL