[ARM/Bicep] az deployment: Fix bicep template size inflation with differential template handling#31953
[ARM/Bicep] az deployment: Fix bicep template size inflation with differential template handling#31953
az deployment: Fix bicep template size inflation with differential template handling#31953Conversation
- Parse escaped JSON template back to original content before concatenation
- Prevents template size inflation that could push deployments over 4MB limit
- Uses compact JSON format (separators=(',', ':')) to minimize size
- Adds error handling with fallback to original template if parsing fails
Fixes Azure#31952
❌AzureCLI-FullTest
|
️✔️AzureCLI-BreakingChangeTest
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
…SSD V2 is no longer supported with Burstable compute tier (Azure#31948)
az deployment: Fix JsonCTemplatePolicy template size inflation causing 4MB limit errors
|
Thanks for your great contribution! Could you please record some yaml files for some related tests in live mode? https://github.com/Azure/azure-cli/blob/dev/doc/authoring_tests.md#recording-tests |
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
…rate CV1 apps to Flex (Azure#31865)
…ange-reference` to support Change Safety feature (Azure#31741)
…mirroring validation to allow updating high availability status for PG11 and PG12 servers (Azure#31944)
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
|
please fix the CI issues. |
…e` `--disable-azure-container-storage` behavior and add `--container-storage-version` (Azure#31966)
- Parse escaped JSON template back to original content before concatenation
- Prevents template size inflation that could push deployments over 4MB limit
- Uses compact JSON format (separators=(',', ':')) to minimize size
- Adds error handling with fallback to original template if parsing fails
Fixes Azure#31952
- Fix trailing whitespace and indentation issues that caused style check failures - Update bicep template processing to use JSON objects instead of escaped strings - Improve comments for better readability and adherence to line length limits - Only apply JsonCTemplatePolicy for ARM template files, not bicep files - Update both _deploy_arm_template_core_unmodified and _prepare_deployment_properties_unmodified functions This resolves CI style check failures while maintaining the core fix for 4MB template size inflation issues.
- Maintained bicep-specific solution with proper comments - Cleaned up formatting inconsistencies from merge
… deployments - Set template_for_deployment to None for URI-based deployments - Update both _deploy_arm_template_core_unmodified and _prepare_deployment_properties_unmodified - Template URI deployments use template_link instead of template content - Fixes test failure: DeploymentThruUriTest::test_group_deployment_thru_uri
az deployment: Fix JsonCTemplatePolicy template size inflation causing 4MB limit errorsaz deployment: Fix bicep template size inflation with differential template handling
|
Closing this PR to create a clean version without the 300+ unrelated file changes. The new clean implementation will be submitted in a new PR. |
|
New PR: #31990 |
Description
Fixes bicep template size inflation that causes false "template too large" errors for deployments near the 4MB limit by implementing differential template processing based on file type.
Problem
The Azure CLI was applying JsonCTemplatePolicy string escaping to all template types, causing significant size inflation for bicep templates. This led to deployment failures for templates under 4MB due to the inflated request payload size.
Root Cause Analysis
Solution Approach
Implemented differential template handling based on file type:
Bicep Files (.bicep)
ARM Template Files (.json)
URI-based Deployments
Key Code Changes
_prepare_deployment_properties_unmodified(): Now uses differential handling where bicep files use JSON objects directly, ARM files use string content, and URI deployments use template links.
_deploy_arm_template_core_unmodified(): JsonCTemplatePolicy is now only applied to ARM template files, not bicep files, preventing unnecessary string escaping.
Impact
Testing
Related Issues
Fixes #31989
Type of Change