Problem
Static Web Apps with managed Azure Functions is a very common Azure pattern — the SWA resource bundles a frontend and a managed Functions API. In azure.yaml, both services must use host: staticwebapp because they deploy to the same SWA resource:
services:
web:
project: .
host: staticwebapp
language: js
api:
project: api
host: staticwebapp
language: js
However, azd app run uses the host property to determine how to run services locally. In detector.go, DetectServiceRuntime() only triggers Functions handling when service.Host == "function":
// Special handling for Azure Functions (all variants including Logic Apps)
if service.Host == "function" {
return buildFunctionsRuntime(serviceName, service, projectDir, usedPorts, azureYamlDir)
}
This means that when host: staticwebapp, the API service misses all Functions auto-detection:
- ❌
func start is not launched for the API service
- ❌
detectFunctionsVariant() (in functions.go) is never called — no v3/v4 model detection
- ❌
InjectFunctionsWorkerRuntime() (in environment.go) is skipped — no FUNCTIONS_WORKER_RUNTIME, no local.settings.json Values injection
- ❌ Functions
/admin/host/status health check is not used
- ❌ Functions port manager is not engaged
The host property is serving dual duty — deployment target AND local dev behavior — and these conflict for the SWA + managed Functions pattern.
Reproduction
- Create a Static Web App project with a managed Functions API (e.g., React frontend + Azure Functions in
api/)
- In
azure.yaml, set both services to host: staticwebapp
- Run
azd app run
- Observe: the API service doesn't start with
func start, doesn't get environment injection, and doesn't get the correct health check
Current Workaround
Users must manually configure what auto-detection would normally provide:
services:
api:
project: api
host: staticwebapp
language: js
command: func start --port 7336
ports: ["7336"]
environment:
AzureWebJobsStorage: UseDevelopmentStorage=true
FUNCTIONS_WORKER_RUNTIME: node
This defeats the purpose of the auto-detection that azd app run provides for host: function services.
Proposed Solutions
Option 1 (Preferred): Auto-detect Functions within staticwebapp services
In DetectServiceRuntime(), when host: staticwebapp and the project directory contains Functions markers (host.json + @azure/functions in deps, function.json files, Python/C#/.NET Functions markers), call buildFunctionsRuntime() for local dev purposes.
The existing detectFunctionsVariant() logic already handles variant detection — it just needs to also be called for staticwebapp host services.
Option 2: Add a localHost or devHost override
services:
api:
host: staticwebapp # For deployment
localHost: function # For azd app run
This separates the deployment target from the local dev behavior explicitly.
Option 3: SWA CLI integration
Detect the SWA + Functions pattern and use swa start to orchestrate both services, since the SWA CLI already handles the reverse proxy and Functions runtime natively.
Impact
This affects anyone using the very common pattern of Static Web Apps with managed Functions — a core Azure serverless pattern. Without this fix, users lose the main benefit of azd app run (zero-config local dev) and have to manually configure command, ports, and environment variables.
Problem
Static Web Apps with managed Azure Functions is a very common Azure pattern — the SWA resource bundles a frontend and a managed Functions API. In
azure.yaml, both services must usehost: staticwebappbecause they deploy to the same SWA resource:However,
azd app runuses thehostproperty to determine how to run services locally. Indetector.go,DetectServiceRuntime()only triggers Functions handling whenservice.Host == "function":This means that when
host: staticwebapp, the API service misses all Functions auto-detection:func startis not launched for the API servicedetectFunctionsVariant()(infunctions.go) is never called — no v3/v4 model detectionInjectFunctionsWorkerRuntime()(inenvironment.go) is skipped — noFUNCTIONS_WORKER_RUNTIME, nolocal.settings.jsonValues injection/admin/host/statushealth check is not usedThe
hostproperty is serving dual duty — deployment target AND local dev behavior — and these conflict for the SWA + managed Functions pattern.Reproduction
api/)azure.yaml, set both services tohost: staticwebappazd app runfunc start, doesn't get environment injection, and doesn't get the correct health checkCurrent Workaround
Users must manually configure what auto-detection would normally provide:
This defeats the purpose of the auto-detection that
azd app runprovides forhost: functionservices.Proposed Solutions
Option 1 (Preferred): Auto-detect Functions within
staticwebappservicesIn
DetectServiceRuntime(), whenhost: staticwebappand the project directory contains Functions markers (host.json+@azure/functionsin deps,function.jsonfiles, Python/C#/.NET Functions markers), callbuildFunctionsRuntime()for local dev purposes.The existing
detectFunctionsVariant()logic already handles variant detection — it just needs to also be called forstaticwebapphost services.Option 2: Add a
localHostordevHostoverrideThis separates the deployment target from the local dev behavior explicitly.
Option 3: SWA CLI integration
Detect the SWA + Functions pattern and use
swa startto orchestrate both services, since the SWA CLI already handles the reverse proxy and Functions runtime natively.Impact
This affects anyone using the very common pattern of Static Web Apps with managed Functions — a core Azure serverless pattern. Without this fix, users lose the main benefit of
azd app run(zero-config local dev) and have to manually configure command, ports, and environment variables.