Support container deployment for Function Apps - #9284
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds container deployment support for Function Apps while preserving zip deployment for code-based functions.
Changes:
- Routes container-configured Function Apps through shared App Service container lifecycle.
- Expands schemas and documentation for container Function configuration.
- Adds unit, sanitizer, and recorded functional coverage with a containerized Node.js fixture.
Show a summary per file
| File | Description |
|---|---|
schemas/v1.0/azure.yaml.json |
Allows Function container configuration. |
schemas/alpha/azure.yaml.json |
Mirrors stable schema support. |
docs/reference/azure-yaml-schema.md |
Documents Function deployment modes. |
cli/azd/test/recording/sanitize.go |
Corrects Container App PATCH filtering. |
cli/azd/test/recording/sanitize_test.go |
Tests sanitizer scope and secrets. |
cli/azd/test/functional/up_test.go |
Adds container Function lifecycle test. |
.../src/functions/hello.js |
Implements fixture HTTP function. |
.../src/function/package.json |
Defines fixture dependencies. |
.../src/function/host.json |
Configures the Function host. |
.../src/function/Dockerfile |
Builds the fixture image. |
.../src/function/.dockerignore |
Excludes local Node artifacts. |
.../infra/resources.bicep |
Provisions Function, ACR, and dependencies. |
.../infra/main.parameters.json |
Supplies fixture deployment parameters. |
.../infra/main.bicep |
Creates the fixture resource group. |
.../containerfuncapp/azure.yaml |
Configures Dockerfile-based Function deployment. |
...ContainerFuncApp.docker.yaml |
Records Docker login and push. |
...ContainerFuncApp.yaml |
Records Azure HTTP interactions. |
cli/azd/pkg/project/service_target_functionapp.go |
Adds container lifecycle routing and mismatch detection. |
.../service_target_functionapp_test.go |
Covers container and zip routing. |
.../service_target_appservice.go |
Centralizes container classification. |
cli/azd/pkg/azapi/webapp.go |
Adds shared site container classification. |
cli/azd/pkg/azapi/webapp_test.go |
Tests site classification cases. |
cli/azd/pkg/azapi/function_app.go |
Exposes Function container configuration. |
.../recording-functional-tests-guide.md |
Documents deterministic recording setup. |
cli/azd/AGENTS.md |
Adds Docker and recording test guidance. |
Review details
- Files reviewed: 24/25 changed files
- Comments generated: 3
- Review effort level: Medium
e320cc7 to
3dcc197
Compare
Deploying to a Function App provisioned as a container (kind:
functionapp,linux,container) sent a zip package to a site that could never
accept one, and ZipDeployClient polled forever with no output. functionAppTarget
now fetches site properties once up front and routes container-configured
services to a container deploy, failing fast with an actionable error when the
service and site disagree in either direction.
Giving Function Apps their own deploy flow also drops the App Service slot
resolution they silently inherited by delegating to appServiceTarget.Deploy.
That inherited path honored AZD_DEPLOY_{SERVICE}_SLOT_NAME, prompted when slots
existed, and hard-failed under --no-prompt: untested, undocumented, and at odds
with the schema, which disables env for host: function. Function Apps now always
deploy to the main site.
Supporting changes:
- Allow docker/image container configuration for host: function in the v1.0 and
alpha azure.yaml schemas, and validate it at initialize time.
- Split isContainerDeploy into config-only and config-plus-artifacts checks, and
extract newDeployArtifacts to replace four duplicated artifact blocks.
- Drop single-caller GetAppServiceContainerConfiguration and return container
configuration by value.
- Nil-guard GetFunctionAppProperties, which panicked on container sites missing
ServerFarmID.
- Fix sanitizer precedence in test recording so specific rules are not shadowed
by general ones.
Adds Test_CLI_Up_Down_ContainerFuncApp with a containerfuncapp sample and
recordings, plus unit coverage for the container and zip branches, the mismatch
errors, and a guard asserting no slot API is called.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9fd3eef8-cc72-4e6c-9e21-18d85eefac55
48b8bc6 to
9eab3b0
Compare
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Review details
Files not reviewed (1)
- cli/azd/test/functional/testdata/samples/containerfuncapp/src/function/package-lock.json: Generated file
Comments suppressed due to low confidence (3)
cli/azd/pkg/project/service_target_functionapp.go:164
- [azd-code-reviewer] Handle pre-built images separately here. For an
image:service, this suggestion tells users to setdocker.remoteBuild, butContainerHelper.Publishthen takes the ACR build path and never uses the declared source image; because the image schema also forbidsproject, this either builds unrelated repository content or fails looking for a Dockerfile. Rejectdocker.remoteBuild: truewhenimageis set and tell image users to remove build settings; mirror that constraint in both schemas.
if containerConfigured(serviceConfig) && serviceConfig.RemoteBuild != nil {
return &internal.ErrorWithSuggestion{
Err: fmt.Errorf("top-level 'remoteBuild' is only supported for code-based function deployments"),
Suggestion: "Remove the top-level setting and use 'docker.remoteBuild' for container deployments.",
schemas/v1.0/azure.yaml.json:539
- [azd-code-reviewer] This image branch still accepts
docker.remoteBuild: true. In that configuration the delegated publisher prioritizesrunRemoteBuild, ignores the declaredimage, and attempts to package a Dockerfile context even though this branch forbidsproject. Constrain nesteddocker.remoteBuildtofalsefor pre-built images so the schema does not validate a configuration that deploys the wrong input or fails later.
"properties": {
"language": { "const": "docker" },
"remoteBuild": false
}
schemas/alpha/azure.yaml.json:579
- [azd-code-reviewer] This image branch still accepts
docker.remoteBuild: true. In that configuration the delegated publisher prioritizesrunRemoteBuild, ignores the declaredimage, and attempts to package a Dockerfile context even though this branch forbidsproject. Constrain nesteddocker.remoteBuildtofalsefor pre-built images so the alpha schema does not validate a configuration that deploys the wrong input or fails later.
"properties": {
"language": { "const": "docker" },
"remoteBuild": false
}
- Files reviewed: 28/30 changed files
- Comments generated: 0 new
- Review effort level: Medium
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fixes #9250
Summary
This PR adds container image deployment support for services configured with
host: function. It reuses the App Service container lifecycle introduced in #8847 while preserving existing zip deployment behavior for code-based Function Apps.Issue
The Function App target previously treated every service as a code package. When the provisioned Function App used
linuxFxVersion=DOCKER|...,azd deploysent an incompatible zip deployment to Kudu and could wait until timeout.host: functionby the Azure YAML schema.Container deployment
Container intent is explicit through
language: docker,docker.path, a prebuiltimage, or a container artifact. azd then uses the existing container helper to build or resolve the image, publish it when required, and update only the site'slinuxFxVersion.docker.remoteBuildbecause the Function target delegates to the shared container publishing path.Behaviour at a glance
linuxFxVersionConfiguration and diagnostics
The stable and alpha schemas now allow Dockerfile and prebuilt-image configuration for Function services. The Azure YAML reference documents both deployment modes and the infrastructure responsibilities for container hosting.
The implementation also centralizes App Service container classification and fixes a recording sanitizer predicate uncovered by the new Function App image PATCH. Follow-up #9283 tracks making functional test prompt handling deterministic across recording principals and playback.
Testing