From d25603774ed491c4c43d95ea355289267f6706ce Mon Sep 17 00:00:00 2001 From: Jesper Fajers Date: Fri, 25 Feb 2022 09:46:04 +0000 Subject: [PATCH 1/4] PSFMessage level update --- src/functions/Invoke-AzOpsPush.ps1 | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/functions/Invoke-AzOpsPush.ps1 b/src/functions/Invoke-AzOpsPush.ps1 index c8cc9289..5745a807 100644 --- a/src/functions/Invoke-AzOpsPush.ps1 +++ b/src/functions/Invoke-AzOpsPush.ps1 @@ -244,13 +244,11 @@ $addition = $transpiledTemplatePath } - try { $scopeObject = New-AzOpsScope -Path $addition -StatePath $StatePath -ErrorAction Stop } - catch { - Write-PSFMessage -Level Warning @common -String 'Invoke-AzOpsPush.Scope.Failed' -StringValues $addition, $StatePath -Target $addition -ErrorRecord $_ - continue + try { + $scopeObject = New-AzOpsScope -Path $addition -StatePath $StatePath -ErrorAction Stop } - if (-not $scopeObject) { - Write-PSFMessage -Level Warning @common -String 'Invoke-AzOpsPush.Scope.NotFound' -StringValues $addition, $StatePath -Target $addition + catch { + Write-PSFMessage -Level Debug @common -String 'Invoke-AzOpsPush.Scope.Failed' -StringValues $addition, $StatePath -Target $addition -ErrorRecord $_ continue } @@ -269,15 +267,14 @@ continue } - try { $scopeObject = New-AzOpsScope -Path $deletion -StatePath $StatePath -ErrorAction Stop } - catch { - Write-PSFMessage -Level Warning @common -String 'Invoke-AzOpsPush.Scope.Failed' -StringValues $deletion, $StatePath -Target $deletion -ErrorRecord $_ - continue + try { + $scopeObject = New-AzOpsScope -Path $deletion -StatePath $StatePath -ErrorAction Stop } - if (-not $scopeObject) { - Write-PSFMessage -Level Warning @common -String 'Invoke-AzOpsPush.Scope.NotFound' -StringValues $deletion, $StatePath -Target $deletion + catch { + Write-PSFMessage -Level Debug @common -String 'Invoke-AzOpsPush.Scope.Failed' -StringValues $deletion, $StatePath -Target $deletion -ErrorRecord $_ continue } + Resolve-ArmFileAssociation -ScopeObject $scopeObject -FilePath $deletion -AzOpsMainTemplate $AzOpsMainTemplate } $WhatIfPreference = $WhatIfPreferenceState @@ -286,7 +283,7 @@ $uniqueProperties = 'Scope', 'DeploymentName', 'TemplateFilePath', 'TemplateParameterFilePath' $deploymentList | Select-Object $uniqueProperties -Unique | Sort-Object -Property TemplateParameterFilePath | New-AzOpsDeployment -WhatIf:$WhatIfPreference - #Removal of RoleAssignments and PolicyAssignments + #Removal of policyAssignment, policyExemption and roleAssignment $uniqueProperties = 'Scope', 'TemplateFilePath' $deletionList | Select-Object $uniqueProperties -Unique | Remove-AzOpsDeployment -WhatIf:$WhatIfPreference From 635febf2f519dbd0211bdce1b158e58aeee22314 Mon Sep 17 00:00:00 2001 From: Jesper Fajers Date: Fri, 25 Feb 2022 17:52:32 +0000 Subject: [PATCH 2/4] PSFMessage level update 2 --- src/localized/en-us/Strings.psd1 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/localized/en-us/Strings.psd1 b/src/localized/en-us/Strings.psd1 index e6b35555..4c537b5f 100644 --- a/src/localized/en-us/Strings.psd1 +++ b/src/localized/en-us/Strings.psd1 @@ -181,7 +181,6 @@ 'Invoke-AzOpsPush.Resolve.ParameterFound' = 'Found parameter file for template {0} : {1}' # $FilePath, $parameterPath 'Invoke-AzOpsPush.Resolve.ParameterNotFound' = 'No parameter file found for template {0} : {1}' # $FilePath, $parameterPath 'Invoke-AzOpsPush.Scope.Failed' = 'Failed to read {0} as part of {1}' # $addition, $StatePath - 'Invoke-AzOpsPush.Scope.NotFound' = 'Skipping {0}, not part of {1}' # $addition, $StatePath 'Invoke-AzOpsNativeCommand.Failed.NoCallstack' = 'Execution of {{{0}}} failed with exit code {1}' # $ScriptBlock, $LASTEXITCODE 'Invoke-AzOpsNativeCommand.Failed.WithCallstack' = 'Execution of {{{0}}} by {1}: line {2} failed with exit code {3}' # $ScriptBlock, $caller[1].ScriptName, $caller[1].ScriptLineNumber, $LASTEXITCODE From 1fd8ccceb4e6f5086c81c49f179a5d97402737f9 Mon Sep 17 00:00:00 2001 From: Jesper Fajers Date: Mon, 28 Feb 2022 10:22:22 +0000 Subject: [PATCH 3/4] PSFMessage level update 3 --- src/functions/Invoke-AzOpsPush.ps1 | 6 ++++++ src/localized/en-us/Strings.psd1 | 1 + 2 files changed, 7 insertions(+) diff --git a/src/functions/Invoke-AzOpsPush.ps1 b/src/functions/Invoke-AzOpsPush.ps1 index 5745a807..642579da 100644 --- a/src/functions/Invoke-AzOpsPush.ps1 +++ b/src/functions/Invoke-AzOpsPush.ps1 @@ -279,6 +279,12 @@ } $WhatIfPreference = $WhatIfPreferenceState + #If addModifySet exists and no deploymentList has been generated, exit with terminating error + if ($addModifySet -and -not $deploymentList) { + Write-PSFMessage -Level Critical @common -String 'Invoke-AzOpsPush.DeploymentList.NotFound' + exit 1 + } + #Starting Tenant Deployment $uniqueProperties = 'Scope', 'DeploymentName', 'TemplateFilePath', 'TemplateParameterFilePath' $deploymentList | Select-Object $uniqueProperties -Unique | Sort-Object -Property TemplateParameterFilePath | New-AzOpsDeployment -WhatIf:$WhatIfPreference diff --git a/src/localized/en-us/Strings.psd1 b/src/localized/en-us/Strings.psd1 index 4c537b5f..34d1955d 100644 --- a/src/localized/en-us/Strings.psd1 +++ b/src/localized/en-us/Strings.psd1 @@ -170,6 +170,7 @@ 'Invoke-AzOpsPush.Deploy.ResourceProvider' = 'Invoking new state deployment - *.resourceproviders.json for a file {0}' # $addition 'Invoke-AzOpsPush.Deploy.Subscription' = 'Invoking new state deployment - *.subscription.json for a file {0}' # $addition 'Invoke-AzOpsPush.Deployment.Required' = 'Deployment required' # + 'Invoke-AzOpsPush.DeploymentList.NotFound' = 'Expecting deploymentList object, it was not found. Exiting runtime with error code 1.' 'Invoke-AzOpsPush.Resolve.ConvertBicepTemplate' = 'Converting Bicep template ({0}) to standard ARM Template JSON ({1})' # $FilePath, $templatePath 'Invoke-AzOpsPush.Resolve.FoundTemplate' = 'Found template {1} for parameters {0}' # $FilePath, $templatePath 'Invoke-AzOpsPush.Resolve.FoundBicepTemplate' = 'Found Bicep template {1} for parameters {0}' # $FilePath, $templatePath From e5069b7c84ef7ccc74de39967958248f613ec2b4 Mon Sep 17 00:00:00 2001 From: Jesper Fajers Date: Mon, 28 Feb 2022 14:11:22 +0000 Subject: [PATCH 4/4] PSFMessage level update 4 --- src/tests/templates/azuredeploy.jsonc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/templates/azuredeploy.jsonc b/src/tests/templates/azuredeploy.jsonc index f4273b2f..cf0e8abd 100644 --- a/src/tests/templates/azuredeploy.jsonc +++ b/src/tests/templates/azuredeploy.jsonc @@ -125,7 +125,7 @@ ], "copy": { "batchSize": 1, - "count": 10, + "count": 25, "mode": "Serial", "name": "waitingCompletion" },