Background & Motivation
Different hook executor types (Python, JS, TS, .NET) have unique configuration needs beyond the shared run, dir, kind, and continueOnError fields. Today there's no mechanism for users to pass executor-specific settings in azure.yaml.
azd already uses a config property bag pattern in several places:
state.RemoteConfig — backend discriminator + Config map[string]any for backend-specific settings
platform.Config — type discriminator + Config map[string]any for platform-specific settings
ServiceConfig — Config map[string]any for service-target-specific settings (e.g., packageManager for Node.js)
Proposal
Add a Config map[string]any field to HookConfig in pkg/ext/models.go, discriminated by the existing Kind field. Each executor receives the raw config bag and can unmarshal it into a strongly-typed struct.
Example azure.yaml
hooks:
postprovision:
run: ./hooks/seed-database.cs
kind: dotnet
config:
configuration: Release
framework: net10.0
hooks:
postprovision:
run: ./hooks/setup.py
kind: python
config:
virtualEnvName: .venv
Implementation Approach
- Add
Config map[string]any to HookConfig (yaml tag: config,omitempty)
- Extend
ExecutionContext to carry the raw config bag to executors
- Each executor optionally unmarshals the config bag into a typed struct (e.g.,
dotnetHookConfig{Configuration string, Framework string}) using mapstructure or encoding/json re-marshal
- Update the JSON schema (
azure.yaml.json) — use a oneOf discriminated on kind to validate per-executor config shapes
- Update
docs/language-hooks.md with per-executor config options
Example Executor Config Types
// dotnet executor
type dotnetHookConfig struct {
Configuration string `json:"configuration"` // Debug, Release
Framework string `json:"framework"` // net8.0, net10.0
}
// python executor
type pythonHookConfig struct {
VirtualEnvName string `json:"virtualEnvName"` // override venv dir name
}
Out of Scope
- Config validation at YAML load time (executors validate their own config)
- Config inheritance from project-level to service-level hooks
Related
Background & Motivation
Different hook executor types (Python, JS, TS, .NET) have unique configuration needs beyond the shared
run,dir,kind, andcontinueOnErrorfields. Today there's no mechanism for users to pass executor-specific settings inazure.yaml.azd already uses a config property bag pattern in several places:
state.RemoteConfig—backenddiscriminator +Config map[string]anyfor backend-specific settingsplatform.Config—typediscriminator +Config map[string]anyfor platform-specific settingsServiceConfig—Config map[string]anyfor service-target-specific settings (e.g.,packageManagerfor Node.js)Proposal
Add a
Config map[string]anyfield toHookConfiginpkg/ext/models.go, discriminated by the existingKindfield. Each executor receives the raw config bag and can unmarshal it into a strongly-typed struct.Example azure.yaml
Implementation Approach
Config map[string]anytoHookConfig(yaml tag:config,omitempty)ExecutionContextto carry the raw config bag to executorsdotnetHookConfig{Configuration string, Framework string}) usingmapstructureorencoding/jsonre-marshalazure.yaml.json) — use aoneOfdiscriminated onkindto validate per-executor config shapesdocs/language-hooks.mdwith per-executor config optionsExample Executor Config Types
Out of Scope
Related