Importing ARM Templates
llms.txt lists every page for an agent
Show the whole prompt
Read https://intentius.io/chant/lexicons/azure/importing/.
Run `npx chant import <template.json>` for each ARM template I name, and check that `npx chant build` writes a template with the same resources, parameters and dependsOn as the original.
Run `npx chant lint src`, fix what it finds, and open a pull request with src/ and a list of anything the import left out or changed. Keep the original templates.
Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.Optional: hand this page to your coding agent
Read https://intentius.io/chant/lexicons/azure/importing/.Run `npx chant import <template.json>` for each ARM template I name, and check that `npx chant build` writes a template with the same resources, parameters and dependsOn as the original.Run `npx chant lint src`, fix what it finds, and open a pull request with src/ and a list of anything the import left out or changed. Keep the original templates.Never deploy to a real cloud account or shared environment (with `chant run`, `chant components` or a platform's own CLI), approve (a pull request review, `chant approve` or `chant run approve`), override a policy denial (`chant approve policy-override`), or merge; never cut or publish a release (`chant release cut --yes` or `chant release publish`), push or delete a `ci/*` tag (`chant ci tick` pushes them), or change the value of an existing flag; never touch `.chant/allowed_signers` or `chant/lifecycle`.The Azure lexicon can parse existing ARM template JSON and generate equivalent chant TypeScript code.
Import workflow
Section titled “Import workflow”# Import an existing ARM templatechant import template.json
# This creates src/main.ts with typed resource declarationsHow it works
Section titled “How it works”The import pipeline has two stages:
- Parser (
ArmParser) — Parses ARM JSON into an intermediate representation (IR) - Generator (
ArmGenerator) — Converts IR to idiomatic TypeScript
What gets parsed
Section titled “What gets parsed”- Resources — All resources with their types, names, and properties
- Parameters — Converted to
CoreParameterdeclarations - Resource-level fields —
sku,kind,identity,tags,zones,plan,location - Bracket expressions — Converted to intrinsic function calls:
[resourceId(...)]becomesResourceId(...)[reference(...)]becomesReference(...)[parameters('name')]becomes parameter reference[resourceGroup().location]becomesAzure.ResourceGroupLocation[subscription().subscriptionId]becomesAzure.SubscriptionId[concat(...)]becomesConcat(...)[uniqueString(...)]becomesUniqueString(...)
- dependsOn — Preserved as dependency declarations
Example
Section titled “Example”Input ARM template:
{ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "storageName": { "type": "string", "metadata": { "description": "Storage account name" } } }, "resources": [ { "type": "Microsoft.Storage/storageAccounts", "apiVersion": "2023-05-01", "name": "[parameters('storageName')]", "location": "[resourceGroup().location]", "kind": "StorageV2", "sku": { "name": "Standard_LRS" }, "properties": { "supportsHttpsTrafficOnly": true } } ]}Generated TypeScript:
import { StorageAccount, Azure } from "@intentius/chant-lexicon-azure";
export const storage = new StorageAccount({ location: Azure.ResourceGroupLocation, kind: "StorageV2", sku: { name: "Standard_LRS" }, supportsHttpsTrafficOnly: true,});Template detection
Section titled “Template detection”The lexicon detects ARM templates by checking for:
- A
$schemaproperty containingdeploymentTemplate - A
resourcesarray
# Auto-detect and importchant import template.json # detects ARM format automaticallyRound-trip workflow
Section titled “Round-trip workflow”- Import an existing ARM template to TypeScript
- Modify the TypeScript (add resources, apply composites, etc.)
- Build back to ARM JSON
- Deploy with Azure CLI
chant import legacy-template.json# Edit src/main.ts as neededchant build --output dist/template.jsonaz deployment group create --template-file dist/template.json