Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 16 additions & 13 deletions src/functions/Invoke-AzOpsPush.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -269,24 +267,29 @@
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

#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

#Removal of RoleAssignments and PolicyAssignments
#Removal of policyAssignment, policyExemption and roleAssignment
$uniqueProperties = 'Scope', 'TemplateFilePath'
$deletionList | Select-Object $uniqueProperties -Unique | Remove-AzOpsDeployment -WhatIf:$WhatIfPreference

Expand Down
2 changes: 1 addition & 1 deletion src/localized/en-us/Strings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -181,7 +182,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
Expand Down
2 changes: 1 addition & 1 deletion src/tests/templates/azuredeploy.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
],
"copy": {
"batchSize": 1,
"count": 10,
"count": 25,
"mode": "Serial",
"name": "waitingCompletion"
},
Expand Down