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
16 changes: 10 additions & 6 deletions src/functions/Invoke-AzOpsPush.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
The root path to where the entire state is being built in.
.PARAMETER AzOpsMainTemplate
Path to the main template used by AzOps
.PARAMETER CustomSortOrder
Switch to honor the input ordering for ChangeSet. If not used, ChangeSet will be sorted in ascending order.
.EXAMPLE
> Invoke-AzOpsPush -ChangeSet changeSet -StatePath $StatePath -AzOpsMainTemplate $templatePath
Applies a change to Azure from the AzOps configuration.
Expand All @@ -33,7 +35,10 @@
$StatePath = (Get-PSFConfigValue -FullName 'AzOps.Core.State'),

[string]
$AzOpsMainTemplate = (Get-PSFConfigValue -FullName 'AzOps.Core.MainTemplate')
$AzOpsMainTemplate = (Get-PSFConfigValue -FullName 'AzOps.Core.MainTemplate'),

[switch]
$CustomSortOrder
)

begin {
Expand Down Expand Up @@ -177,9 +182,8 @@
}
if ($operation -in 'A', 'M', 'R' -or $operation -match '^R0[0-9][0-9]$') { $filename }
}
if ($deleteSet) { $deleteSet = $deleteSet | Sort-Object }
if ($addModifySet) { $addModifySet = $addModifySet | Sort-Object }
# TODO: Clarify what happens with the deletes - not used after reporting them
if ($deleteSet -and -not $CustomSortOrder) { $deleteSet = $deleteSet | Sort-Object }
if ($addModifySet -and -not $CustomSortOrder) { $addModifySet = $addModifySet | Sort-Object }

Write-PSFMessage -Level Important @common -String 'Invoke-AzOpsPush.Change.AddModify'
foreach ($item in $addModifySet) {
Expand Down Expand Up @@ -262,7 +266,7 @@
}

$templateContent = Get-Content $deletion | ConvertFrom-Json -AsHashtable
if (-not($templateContent.resources[0].type -in "Microsoft.Authorization/policyAssignments","Microsoft.Authorization/policyExemptions","Microsoft.Authorization/roleAssignments")) {
if (-not($templateContent.resources[0].type -in "Microsoft.Authorization/policyAssignments", "Microsoft.Authorization/policyExemptions", "Microsoft.Authorization/roleAssignments")) {
Write-PSFMessage -Level Warning -String 'Remove-AzOpsDeployment.SkipUnsupportedResource' -StringValues $deletion -Target $scopeObject
continue
}
Expand All @@ -287,7 +291,7 @@

#Starting Tenant Deployment
$uniqueProperties = 'Scope', 'DeploymentName', 'TemplateFilePath', 'TemplateParameterFilePath'
$deploymentList | Select-Object $uniqueProperties -Unique | Sort-Object -Property TemplateParameterFilePath | New-AzOpsDeployment -WhatIf:$WhatIfPreference
$deploymentList | Select-Object $uniqueProperties -Unique | New-AzOpsDeployment -WhatIf:$WhatIfPreference

#Removal of policyAssignment, policyExemption and roleAssignment
$uniqueProperties = 'Scope', 'TemplateFilePath'
Expand Down
Loading