From 391bdc42a9b82744c0dd9988855f88224b152cfb Mon Sep 17 00:00:00 2001 From: Pardha Vallapreddy <39433011+pardhasaradhireddy@users.noreply.github.com> Date: Tue, 17 Feb 2026 16:27:42 -0600 Subject: [PATCH] Fix DryRun not loading deployment state from storage for hash comparison When running Publish-AdfV2FromJson with -DryRun flag, the deployment state was not being loaded from Azure Storage, causing the hash comparison to run against an empty state. This resulted in all objects being marked as changed instead of only showing actual changes. The Get-StateFromStorage call was inside the (!$DryRun.IsPresent) block, which skipped loading the state during dry runs. Moved the state loading outside this block so it executes for both DryRun and normal deployments. This is a read-only operation and safe for DryRun mode. The Set-StateToStorage (write operation) still only executes after actual deployment, not during DryRun. Fixes: DryRun showing all objects as changed when incremental deployment is enabled --- public/Publish-AdfV2FromJson.ps1 | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/public/Publish-AdfV2FromJson.ps1 b/public/Publish-AdfV2FromJson.ps1 index 3566a27..0f079e0 100644 --- a/public/Publish-AdfV2FromJson.ps1 +++ b/public/Publish-AdfV2FromJson.ps1 @@ -154,10 +154,6 @@ function Publish-AdfV2FromJson { $targetAdf = Get-AzDataFactoryV2 -ResourceGroupName "$ResourceGroupName" -Name "$DataFactoryName" -ErrorAction:Ignore if ($targetAdf) { Write-Host "Azure Data Factory exists." - if ($opt.IncrementalDeployment -and !$DryRun.IsPresent) { - Write-Host "Loading Deployment State from Storage..." - $ds = Get-StateFromStorage -DataFactoryName $DataFactoryName -LocationUri $opt.IncrementalDeploymentStorageUri - } } else { $msg = "Azure Data Factory instance does not exist." @@ -175,13 +171,19 @@ function Publish-AdfV2FromJson { if ($null -eq $targetAdf) { Write-Host "ADFT0032: The process is exiting the function. Do fix the issue and run again." - return + return } } else { Write-Host "DRY RUN: Skipping ADF existence verification..." } + # Load deployment state from storage for incremental deployment (needed for both DryRun and actual deployment) + if ($opt.IncrementalDeployment) { + Write-Host "Loading Deployment State from Storage..." + $ds = Get-StateFromStorage -DataFactoryName $DataFactoryName -LocationUri $opt.IncrementalDeploymentStorageUri + } + Write-Host "==================================================================================="; Write-Host "STEP: Reading Azure Data Factory from JSON files..." $adf = Import-AdfFromFolder -FactoryName $DataFactoryName -RootFolder "$RootFolder"