Chapter 16 · Azure Enterprise Infra Planner
Subchapter 16.1
references/bicep-generation.mdMarkdown4 KBView on GitHub
Generate Bicep IaC files from the approved infrastructure plan.
Important: All Bicep files must be created under
<project-root>/infra/. Never place.bicepfiles in the project root or in.azure/.
Generate files under <project-root>/infra/:
infra/
├── main.bicep # Orchestrator — deploys all modules
├── main.bicepparam # Parameter values
└── modules/
├── storage.bicep # One module per resource or logical group
├── compute.bicep
├── networking.bicep
└── monitoring.bicepinfra/ directory — create <project-root>/infra/ and <project-root>/infra/modules/ directories. All files in subsequent steps go here.<project-root>/.azure/infrastructure-plan.json, verify meta.status === "approved"bicepschema_get with resource-type set to the ARM type from the relevant resources/ category file (e.g., Microsoft.ContainerService/managedClusters). Instruct the sub-agent: “Return the full property structure for {ARM type}: required properties, allowed values, child resources. ≤500 tokens.” Use this output — not training data — to generate correct resource definitions.The schema tool returns only the schema for the exact type requested. Sub-resource types (e.g.,
Microsoft.Network/virtualNetworks/subnets) return a smaller, focused schema but miss parent-level properties (e.g., VNetencryptionlives on the parent, not the subnet sub-resource). Strategy:
- Start with sub-resource types when validating child resources — smaller responses (~25KB vs ~95KB), easier to summarize
- Fetch the parent type separately when you need parent-level properties (encryption, tags, SKU) — delegate to a sub-agent with specific property extraction instructions to manage the large response
.bicep file per group under infra/modules/. Use the schema from step 3 for property names, allowed values, and required fields.infra/main.bicep that imports all modules and passes parametersinfra/main.bicepparam with environment-specific values@description() decorators on all parameters@secure() for secrets and connection stringstargetScope in main.bicep based on the deployment plan:
targetScope = 'resourceGroup' and deploy with az deployment group create.targetScope = 'subscription' and deploy with az deployment sub create.existing keyword for referencing pre-existing resourcesdependsOn only when implicit dependencies are insufficientusing './main.bicep'
param location = 'eastus'
param environmentName = 'prod'
param workloadName = 'datapipeline'For multi-environment plans, generate one parameter file per environment:
infra/
├── main.bicep
├── main.dev.bicepparam
├── main.staging.bicepparam
└── main.prod.bicepparamRun az bicep build --file infra/main.bicep to validate syntax before deploying.