Azure Infrastructure Blog | 5 min read | Shivani Joshi, Microsoft
Enterprise landing zones increasingly disable public network access on every PaaS service. That is the right security posture, but it breaks the default container delivery path: a Microsoft-hosted agent cannot reach a private Azure Container Registry (ACR), and a Function App cannot pull its image unless the pull is explicitly routed through the virtual network. In this post, we walk through a production-tested Azure DevOps pattern that builds a containerized Python Azure Function on self-hosted agents, pushes it to a private Premium ACR and deploys it to a private Linux Function App, with no public endpoint anywhere in the path.
Problem Statement
Across customer engagements, the same gaps appear when teams move container workloads into a locked-down landing zone:
- Microsoft-hosted agents cannot push to an ACR with public network access disabled.
- The Function App fails to start with an image pull error because the pull goes over the public path by default.
- Private DNS for the registry is incomplete, so the agent or the app resolves the public IP.
- Identities are over-privileged (subscription Contributor, AcrPush on the runtime identity) to "make it work".
The result is either a failed deployment or a design that quietly reopens public access.
Solution Overview
The pipeline is split into three planes, each fully private:
|
Plane |
Component |
Private connectivity |
|
Build |
Self-hosted VM agent pool per environment |
Runs inside the spoke VNet; egress through the hub firewall |
|
Registry |
Azure Container Registry (Premium) |
Private endpoint, public access disabled, admin user off |
|
Run |
Container Function App (App Service plan) |
Inbound private endpoint, VNet integration, image pull over VNet |
Prerequisites
|
Area |
Requirement |
|
Network |
Spoke VNet with separate subnets for agents, private endpoints and Function App VNet integration (delegated to Microsoft.Web/serverFarms) |
|
Private DNS |
privatelink.azurecr.io (registry and regional data endpoint), privatelink.azurewebsites.net, and privatelink blob, queue, table and file zones for the Function storage account, all linked to the spoke or resolved through the hub DNS resolver |
|
Firewall egress (agents) |
Azure DevOps service and agent download endpoints, Microsoft Entra ID sign-in, mcr.microsoft.com for base images, and the package feeds the Dockerfile uses (for example PyPI) |
|
Build agent |
Linux VM with Docker Engine, Azure CLI and the Azure Pipelines agent; agent account in the docker group |
|
Service connection |
Azure Resource Manager connection (workload identity federation recommended) scoped to the environment resource group |
|
Registry |
Premium SKU (required for private endpoints) |
|
Hosting |
Function App on a Linux App Service plan (Basic or higher, or Elastic Premium) for VNet integration |
How the Pipeline Works
Step 1: Build on a private agent
Each environment runs on its own agent pool inside its own network boundary. The image is tagged with the build ID so every deployment is traceable to a run.
- stage: DEV_BuildAndPush
pool:
name: $(dev_poolName) # <dev-agent-pool>
jobs:
- job: Build
workspace:
clean: all
steps:
- checkout: self
clean: true
- task: Bash@3
displayName: Build Docker image
inputs:
targetType: inline
script: |
set -e
docker build --no-cache --pull \
-f $(dockerfilePath) \
-t $(dev_acrLoginServer)/$(imageName):$(buildTag) \
<function-source-folder>
Step 2: Push over the private endpoint
The service connection signs in to the registry through Microsoft Entra ID; no admin credentials are stored. Because the agent resolves the registry to its private IP, the push never leaves the VNet.
- task: AzureCLI@2
displayName: Push image to ACR
inputs:
azureSubscription: $(dev_azureServiceConnection) # <svc-conn>
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
set -e
az acr login --name $(dev_acrName)
docker push $(dev_acrLoginServer)/$(imageName):$(buildTag)
Step 3: Deploy to the Function App
The deploy stage applies environment app settings from source control, then points the app at the new tag.
inlineScript: |
set -e
az functionapp config appsettings set \
--name $(dev_functionAppName) --resource-group $(dev_resourceGroup) \
--settings @scripts/parameters/dev.functionapp-settings.json
az functionapp config set \
--name $(dev_functionAppName) --resource-group $(dev_resourceGroup) \
--linux-fx-version "DOCKER|$(dev_acrLoginServer)/$(imageName):$(buildTag)"
az functionapp restart \
--name $(dev_functionAppName) --resource-group $(dev_resourceGroup)
Step 4: Pull the image over the virtual network (the critical setting)
This is the setting most teams miss. With VNet integration alone, the platform still pulls the container image over the public path, so a private ACR rejects it. Enable Pull image over virtual network in the Deployment Center (or Container image pull under outbound traffic configuration on newer portal experiences), and use the managed identity for registry authentication.
az resource update --resource-group <rg> --name <function-app> \
--resource-type "Microsoft.Web/sites" \
--set properties.vnetImagePullEnabled=true
az functionapp config set --resource-group <rg> --name <function-app> \
--generic-configurations '{"acrUseManagedIdentityCreds": true}'
Step 5: Verify and promote
A verify stage confirms the app reports Running before a ManualValidation gate releases the same pipeline into TEST and STAGE, each with its own agent pool, registry and service connection.
Identity and RBAC (least privilege)
|
Identity |
Role |
Scope |
|
Pipeline service principal |
AcrPush |
Registry |
|
Pipeline service principal |
Website Contributor |
Function App |
|
Function App managed identity |
AcrPull |
Registry |
|
Function App managed identity |
Data-plane roles it actually uses (Storage, Key Vault Secrets User, AI Search) |
Specific resources |
Hardening Checklist
Reviewing the as-built environment surfaced improvements worth applying to any implementation of this pattern:
|
Finding |
Recommendation |
|
Runtime identity holds AcrPush |
Keep AcrPull only; push belongs to the pipeline identity |
|
Service principal has subscription-wide Contributor |
Scope to AcrPush on the registry and Website Contributor on the app |
|
Key Vault Secrets Officer on the runtime identity |
Use Key Vault Secrets User (read only) |
|
SCM and FTP basic-auth publishing enabled |
Disable both; deployments use Microsoft Entra ID |
|
CORS allows a localhost origin |
Remove from non-development environments |
|
Health check not configured |
Enable a health check path |
|
Approval gate pool misconfigured, no notified approvers |
Run ManualValidation in an agentless job (pool: server) and set approvers |
|
Registry retention and soft delete disabled |
Enable retention for untagged manifests; consider deploying by digest |
Troubleshooting
|
Symptom |
Likely cause |
Fix |
|
docker push times out or returns 403 |
Agent resolves the registry public IP |
Check the privatelink.azurecr.io zone link, including the regional data endpoint record |
|
Function App shows ImagePullFailure |
Image pull not routed through the VNet, or missing AcrPull |
Enable Pull image over virtual network; assign AcrPull to the app identity |
|
az acr login fails on the agent |
Docker not running or agent account not in the docker group |
Start Docker; add the agent account to the docker group and restart the agent |
|
Function App starts but host errors |
Storage account private endpoints or DNS missing |
Add blob, queue, table and file private endpoints and zones |
Key Takeaways
- A private registry needs a private builder: self-hosted agents inside the VNet are the foundation.
- VNet integration is not enough; enable image pull over the virtual network explicitly.
- Authenticate everywhere with Microsoft Entra ID and managed identities, never registry admin credentials.
- Separate push and pull identities and scope roles to the resource, not the subscription.
- Treat private DNS as part of the deployment, not an afterthought.
Published Nov 30, 2026
Version 1.0shivanijoshi
Microsoft
Joined April 30, 2026
Azure Infrastructure Blog
Follow this blog board to get notified when there's new activity