-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Closed
Labels
Auto-AssignAuto assign by botAuto assign by botAzure Deploymentsaz deployment/bicep/stack/deployment-scripts/ts/group exportaz deployment/bicep/stack/deployment-scripts/ts/group exportPossible-SolutionService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.Similar-Issue
Description
Problem
Azure CLI deployments of bicep templates near the 4MB size limit fail with "template too large" errors due to unnecessary size inflation during processing.
Root Cause
The issue occurs because:
- JsonCTemplatePolicy string escaping: When processing bicep templates, the CLI converts them to JSON strings and applies JsonCTemplatePolicy, which escapes special characters (quotes, newlines, backslashes)
- Size inflation: The escaped JSON strings become significantly larger than the original template content
- False 4MB limit errors: Templates under 4MB fail due to the inflated request payload size
Example Impact
A 3.2MB bicep template becomes ~4.1MB after string escaping, causing deployment failures even though the original template is well under the Azure limit.
Current Workaround
Users must manually reduce template size or split into smaller templates, even when the original template is within Azure's limits.
Proposed Solution
Implement differential template handling:
- Bicep files: Use JSON objects directly (no string escaping/JsonCTemplatePolicy)
- ARM template files: Continue using string content with JsonCTemplatePolicy
- URI-based deployments: Use template_link without local processing
This maintains backward compatibility while fixing the size inflation issue for bicep templates.
Metadata
Metadata
Assignees
Labels
Auto-AssignAuto assign by botAuto assign by botAzure Deploymentsaz deployment/bicep/stack/deployment-scripts/ts/group exportaz deployment/bicep/stack/deployment-scripts/ts/group exportPossible-SolutionService AttentionThis issue is responsible by Azure service team.This issue is responsible by Azure service team.Similar-Issue