lpains.azdiff 1.0.0-rc1

This is a prerelease version of lpains.azdiff.
dotnet tool install --global lpains.azdiff --version 1.0.0-rc1                
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest # if you are setting up this repo
dotnet tool install --local lpains.azdiff --version 1.0.0-rc1                
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=lpains.azdiff&version=1.0.0-rc1&prerelease                
nuke :add-package lpains.azdiff --version 1.0.0-rc1                

azdiff

azdiff is a command-line tool designed to perform deep comparisons between Azure resources.

Installation

dotnet tool install --global lpains.azdiff --prerelease

General usage

Upon installation, access the tool by executing azdiff in your terminal. For specific command details, refer to the sections below or utilize the CLI help via azdiff -h.

The commands provided typically require a source and a target, generating a distinct .diff file for each identified and compared resource.

azdiff arm

Facilitates the comparison between two ARM template files, analyzing Azure resources present in each file and generating one .diff file per resource illustrating the differences between the source and target resources.

  azdiff arm --sourceFile
             --targetFile
             [--outputFolder]
             [--ignoreType]
             [--replaceStringsFile]
             [-?, -h, --help]

Examples

Basic usage:

azdiff arm --sourceFile .\source.json `
           --targetFile .\target.json

Advanced usage:

azdiff arm --sourceFile .\source.json `
           --targetFile .\target.json `
           --ignoreType "Microsoft.Web/staticSites/customDomains" `
           --ignoreType "Microsoft.Web/staticSites/databaseConnections" `
           --replaceStringsFile .\replaceStrings.json

Output file (diff_stapp-blog-centralus-001.diff):

  {
    "type": "Microsoft.Web/staticSites",
    "apiVersion": "2023-01-01",
    "name": "stapp-blog-centralus-001",
    "location": "Central US",
    "sku": {
      "name": "Free",
      "tier": "Free"
    },
    "properties": {
      "repositoryUrl": "https://github.com/jlucaspains/blog-v2",
-     "branch": "v1",
+     "branch": "release/v1",
      "stagingEnvironmentPolicy": "Enabled",
      "allowConfigFileUpdates": true,
      "provider": "GitHub",
      "enterpriseGradeCdnStatus": "Disabled"
    }
  }

Parameters

--sourceFile (required)

The comparison source json file. It should be an exported ARM template.

--targetFile (required)

The comparison target json file. It should be an exported ARM template.

--outputFolder

The folder path for output. Defaults to diffs.

--ignoreType

A list of types to ignore in the ARM comparison. You may use this option multiple times.

--replaceStringsFile

JSON file containing replacement strings. Example:

[
    {
        "target": "Name",
        "input": "DEV",
        "replacement": "env"
    }
]

The target property indicates whether the name (target: Name) property or the whole file (target: Body) will apply replacements. This is particularly useful when dealing with environment comparison (e.g.: DEV vs TEST) where the resource names or parts of its json will differ in a predictable way.

azdiff rg

Facilitates the comparison between two Azure Resource Groups, analyzing Azure resources present in each resource group and generating one .diff file per resource illustrating the differences between the source and target resources.

  azdiff rg --sourceResourceGroupId
             --targetResourceGroupId
             [--outputFolder]
             [--ignoreType]
             [--replaceStringsFile]
             [--authenticationMethod]
             [-?, -h, --help]

Azure Authentication

The azdiff rg uses the DefaultAzureCredential credential provider to authenticate with Azure. It will try a series of authentication methods and use the first successful one or an interactive session if none of the methods succeed.

For more information, see Authenticate with Azure libraries for .NET.

Examples

Basic usage:

azdiff rg --sourceResourceGroupId /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-dev-001 `
          --targetResourceGroupId /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-test-001

Advanced usage:

azdiff rg --sourceResourceGroupId /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-dev-001 `
          --targetResourceGroupId /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-test-001 `
          --ignoreType "Microsoft.Web/staticSites/customDomains" `
          --ignoreType "Microsoft.Web/staticSites/databaseConnections" `
          --replaceStringsFile .\replaceStrings.json

Output file (diff_stapp-blog-centralus-001.diff):

  {
    "type": "Microsoft.Web/staticSites",
    "apiVersion": "2023-01-01",
    "name": "stapp-blog-centralus-001",
    "location": "Central US",
    "sku": {
      "name": "Free",
      "tier": "Free"
    },
    "properties": {
      "repositoryUrl": "https://github.com/jlucaspains/blog-v2",
-     "branch": "v1",
+     "branch": "release/v1",
      "stagingEnvironmentPolicy": "Enabled",
      "allowConfigFileUpdates": true,
      "provider": "GitHub",
      "enterpriseGradeCdnStatus": "Disabled"
    }
  }

Parameters

--sourceResourceGroupId (required)

The comparison source resource group id.

--targetResourceGroupId (required)

The comparison target resource group id.

--outputFolder

The folder path for output. Defaults to diffs.

--ignoreType

A list of types to ignore in the ARM comparison. You may use this option zero to multiple times.

--replaceStringsFile

JSON file containing replacement strings. Example:

[
    {
        "target": "Name",
        "input": "DEV",
        "replacement": "env"
    }
]
--authenticationMethod

Authentication method for connecting to Azure Resource Manager. Default value is DefaultAzureCredential.

Valid options are:

  1. DefaultAzureCredential
  2. EnvironmentCredential
  3. WorkloadIdentityCredential
  4. ManagedIdentityCredential
  5. SharedTokenCacheCredential
  6. VisualStudioCredential
  7. VisualStudioCodeCredential
  8. AzureCliCredential
  9. AzurePowerShellCredential
  10. AzureDeveloperCliCredential
  11. InteractiveBrowserCredential

The target property indicates whether the name (target: Name) property or the whole file (target: Body) will apply replacements. This is particularly useful when dealing with environment comparison (e.g.: DEV vs TEST) where the resource names or parts of its json will differ in a predictable way.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last updated
1.0.0-rc1 92 4/11/2024
1.0.0-beta1 162 12/11/2023
1.0.0-alpha2 77 12/9/2023
1.0.0-alpha1 98 12/3/2023