A tool to compare ARM templates (Azure).
Project description
ARM Compare
ARM Compare is a Python script designed to compare two Azure Resource Manager (ARM) template export files. The script focuses on comparing the configuration attributes of resources, generating a detailed report that includes both a summary and a full property-by-property comparison for each matched resource.
The report contains clickable anchors in the summary table, allowing you to jump directly to the detailed comparison for any resource.
Features
-
Resource Pairing by Type and Name:
Automatically pairs resources based on their type and name. You can also provide custom mappings in a YAML configuration file if resource names differ. -
Enhanced Prefix-Based Resource Mapping:
When you provide a mapping with a base resource type and name, child resources are automatically paired by appending any additional segments. For example, a mapping defined for
Microsoft.Storage/storageAccountswith namestorage001will automatically map a resource such as
Microsoft.Storage/storageAccounts/blobServiceswith namestorage001/defaultto the corresponding target by appending/blobServicesand/defaultto the right-side mapping. -
Wildcard Ignore Rules:
Exclude specific properties from the comparison using wildcard patterns (e.g.,tags.*ordependsOn*). -
Detailed Report Generation:
Generates a report with a summary table and detailed comparison tables. For Markdown output, the tables list properties side-by-side with a Fail column marking differences using a cross (✗). -
Clickable Anchors:
The resource names in the summary are clickable links that scroll down to their detailed comparison sections.
Download or Install
PyPI
pip install azure-arm-compare
Once installed, you can use the command-line tool by running:
arm-compare --help
Or, if you prefer to use it programmatically in your Python code:
import arm_compare
# For example, to invoke the main function:
arm_compare.main()
GitHub clone
-
Clone the Repository:
git clone https://github.com/Philcartmell/azure-arm-compare.git cd azure-arm-compare
-
Install Dependencies:
pip install -r requirements.txt
How to Use It
See samples folder.
Run the script using the command line with the following arguments:
--left: Path to the left ARM template JSON file.--right: Path to the right ARM template JSON file.--config: (Optional) Path to a YAML configuration file.--output: Path to the output file where the comparison result will be saved.--format: (Optional) Output format: eithermarkdownorhtml(default).
Exporting ARM Templates
When exporting ARM templates from Azure, ensure that you exclude parameters. This ensures that resource names remain fixed in the output, which is critical for accurate comparisons.
Configuration
A YAML configuration file is optional but recommended if your ARM templates use different resource names for corresponding resources. Use the configuration file to define additional ignore rules and resource mappings.
Sample YAML Configuration (config.yaml)
The config.yaml file is optional, but unless the resource names are identical you'll probably want to provide it.
ignoreRules:
- "name"
- "dependsOn*"
resourceMappings:
- leftResourceType: "Microsoft.Storage/storageAccounts"
leftResourceName: "storage001"
rightResourceType: "Microsoft.Storage/storageAccounts"
rightResourceName: "storage002"
- ignoreRules: A list of property paths to ignore during comparison. Wildcards are supported.
- resourceMappings:
A list of mappings to manually pair resources if their names differ between the left and right ARM templates. The enhanced mapping logic supports prefix-based matching so that if a resource’s type and name start with the specified mapping values, any additional segments (child resources) are automatically appended to the right-side mapping.
Example Execution
python arm-compare.py --left samples/left.json --right samples/right.json --config config.yaml --output sample_output.md
Release History
Version 0.0.4
Adjustments related to Issue 7
- The output file is now explictly encoded using utf-8
- Removal of unicode ✗ symbol \u2717 and replaced with standard ASCII 'X'.
Version 0.0.3
No functional changes - Fix to PyPI release.
Version 0.0.2
- HTML as Default Output: HTML output is now the default output format.
- Expandable Value Cells:
For HTML output, if a left or right value exceeds 64 characters, the script truncates it and provides a[more]link. Clicking the link expands the full value and toggles to[less]to collapse it again. - Row Highlight on Click:
In HTML output, clicking on a cell in the Property Path column highlights the entire row in yellow, making it easier to compare properties across the row. - Enhanced Summary:
The summary table now includes an additional "Ignored" column. The summary aggregates the counts so that the sum of Ignored, Correct, and Incorrect equals the Total Properties compared.
Version 0.0.1 (Initial Release)
- Markdown Report Generation:
Initially generated a Markdown report with a summary table and detailed property-by-property comparisons. - Resource Pairing by Type and Name:
Automatic pairing of resources by type and name with clickable anchors in the summary. - Enhanced Prefix-Based Resource Mapping:
Support for prefix-based matching in resource mappings. - Wildcard Ignore Rules:
Ability to ignore properties using wildcard patterns.
Contributing
Contributions and improvements are welcome! Feel free to fork the repository and submit pull requests for enhancements or bug fixes.
License
This project is licensed under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file azure_arm_compare-0.0.4.tar.gz.
File metadata
- Download URL: azure_arm_compare-0.0.4.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac74d4d81d1f4e5dfc089564121ac8a94d3db8d7806260703768e6e83f920235
|
|
| MD5 |
3b457a4f7b63ed4c5fc8680a4098b45b
|
|
| BLAKE2b-256 |
e26777bbf623ef5086817554ffe817147fe12557ea1df956865a16c12e9e0e16
|
Provenance
The following attestation bundles were made for azure_arm_compare-0.0.4.tar.gz:
Publisher:
publish.yml on Philcartmell/azure-arm-compare
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
azure_arm_compare-0.0.4.tar.gz -
Subject digest:
ac74d4d81d1f4e5dfc089564121ac8a94d3db8d7806260703768e6e83f920235 - Sigstore transparency entry: 174249289
- Sigstore integration time:
-
Permalink:
Philcartmell/azure-arm-compare@c79f7a54cb10af57b159895d448476b7b5ae936c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Philcartmell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c79f7a54cb10af57b159895d448476b7b5ae936c -
Trigger Event:
push
-
Statement type:
File details
Details for the file azure_arm_compare-0.0.4-py3-none-any.whl.
File metadata
- Download URL: azure_arm_compare-0.0.4-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1343a06df78ac7a8d6473fc8b4df8007f4f5d04f6f66cd3d9f6103f326d946dd
|
|
| MD5 |
f149e31fa06c75f340d7958fa5ecc860
|
|
| BLAKE2b-256 |
2f143db0f87a6f2d61bf74a8bc7b86cf37c8d965652263670e0685f5f54d0344
|
Provenance
The following attestation bundles were made for azure_arm_compare-0.0.4-py3-none-any.whl:
Publisher:
publish.yml on Philcartmell/azure-arm-compare
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
azure_arm_compare-0.0.4-py3-none-any.whl -
Subject digest:
1343a06df78ac7a8d6473fc8b4df8007f4f5d04f6f66cd3d9f6103f326d946dd - Sigstore transparency entry: 174249290
- Sigstore integration time:
-
Permalink:
Philcartmell/azure-arm-compare@c79f7a54cb10af57b159895d448476b7b5ae936c -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Philcartmell
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c79f7a54cb10af57b159895d448476b7b5ae936c -
Trigger Event:
push
-
Statement type: