Skip to content

Commit 2aee3f8

Browse files
authored
Bump Dependencies (#897)
* UpdateBase * Update * Update * Update * Update * Update * Update * Update * Update * Update
1 parent 8874041 commit 2aee3f8

13 files changed

+113
-124
lines changed

scripts/Remove-AzOpsTestsDeployment.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
foreach ($subscription in $cleanupSub) {
7070
$null = Set-AzContext -SubscriptionId $subscription.Id
7171
$null = Get-AzResourceLock | Remove-AzResourceLock -Force
72+
Start-Sleep -Seconds 15
7273
$script:resourceGroups = Get-AzResourceGroup | Where-Object {$_.ResourceGroupName -like "*-azopsrg"}
7374
$script:roleAssignmentsCleanBase = Get-AzRoleAssignment | Where-Object {$_.Scope -ne "/"}
7475
$script:roleAssignments = foreach ($roleAssignment in $script:roleAssignmentsCleanBase) {

src/AzOps.psd1

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Customer Architecture Team (CAT)
55
#
6-
# Generated on: 06/26/2024
6+
# Generated on: 9/3/2024
77
#
88

99
@{
@@ -51,11 +51,11 @@ PowerShellVersion = '7.2'
5151
# ProcessorArchitecture = ''
5252

5353
# Modules that must be imported into the global environment prior to importing this module
54-
RequiredModules = @(@{ModuleName = 'PSFramework'; RequiredVersion = '1.10.318'; },
55-
@{ModuleName = 'Az.Accounts'; RequiredVersion = '2.19.0'; },
56-
@{ModuleName = 'Az.Billing'; RequiredVersion = '2.0.3'; },
57-
@{ModuleName = 'Az.ResourceGraph'; RequiredVersion = '0.13.1'; },
58-
@{ModuleName = 'Az.Resources'; RequiredVersion = '6.16.2'; })
54+
RequiredModules = @(@{ModuleName = 'PSFramework'; RequiredVersion = '1.11.343'; },
55+
@{ModuleName = 'Az.Accounts'; RequiredVersion = '3.0.4'; },
56+
@{ModuleName = 'Az.Billing'; RequiredVersion = '2.0.4'; },
57+
@{ModuleName = 'Az.ResourceGraph'; RequiredVersion = '1.0.0'; },
58+
@{ModuleName = 'Az.Resources'; RequiredVersion = '7.4.0'; })
5959

6060
# Assemblies that must be loaded prior to importing this module
6161
# RequiredAssemblies = @()
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
del(.ResourceId, .ResourceGroupName, .SubscriptionId, .SystemData, .Properties.CreatedOn, .Properties.UpdatedOn, .Properties.CreatedBy, .Properties.UpdatedBy)
1+
del(.ResourceId, .resourceGroup, .subscriptionId, .properties.metadata.createdOn, .properties.metadata.updatedOn, .properties.metadata.createdBy, .properties.metadata.updatedBy, .properties.metadata.assignedBy)

src/data/template/Microsoft.Authorization/policyExemptions.template.jq

-20
This file was deleted.

src/internal/functions/Get-AzOpsPolicy.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@
5454
Write-AzOpsMessage -LogLevel Verbose -LogString 'Get-AzOpsResourceDefinition.Processing.Detail' -LogStringValues 'Policy Assignments', $ScopeObject.Scope
5555
$policyAssignments = Get-AzOpsPolicyAssignment -ScopeObject $ScopeObject -Subscription $Subscription -SubscriptionsToIncludeResourceGroups $SubscriptionsToIncludeResourceGroups -ResourceGroup $ResourceGroup
5656
$policyAssignments | ConvertTo-AzOpsState -StatePath $StatePath
57+
# Process policy exemptions
58+
Write-AzOpsMessage -LogLevel Verbose -LogString 'Get-AzOpsResourceDefinition.Processing.Detail' -LogStringValues 'Policy Exemptions', $ScopeObject.Scope
59+
$policyExemptions = Get-AzOpsPolicyExemption -ScopeObject $ScopeObject -Subscription $Subscription -SubscriptionsToIncludeResourceGroups $SubscriptionsToIncludeResourceGroups -ResourceGroup $ResourceGroup
60+
$policyExemptions | ConvertTo-AzOpsState -StatePath $StatePath
5761
}
5862

5963
}

src/internal/functions/Get-AzOpsPolicyAssignment.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
Discover all custom policy assignments deployed at Management Group scope
1919
#>
2020

21-
[OutputType([Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.Policy.PsPolicyAssignment])]
21+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IPolicyAssignment])]
2222
[CmdletBinding()]
2323
param (
2424
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]

src/internal/functions/Get-AzOpsPolicyDefinition.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Discover all custom policy definitions deployed at Management Group scope
1515
#>
1616

17-
[OutputType([Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.Policy.PsPolicyDefinition])]
17+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IPolicyDefinition])]
1818
[CmdletBinding()]
1919
param (
2020
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]

src/internal/functions/Get-AzOpsPolicyExemption.ps1

+34-19
Original file line numberDiff line numberDiff line change
@@ -7,46 +7,61 @@
77
Discover all custom policy exemptions at the provided scope (Management Groups, subscriptions or resource groups)
88
.PARAMETER ScopeObject
99
The scope object representing the azure entity to retrieve excemptions for.
10+
.PARAMETER Subscription
11+
Complete Subscription list
12+
.PARAMETER SubscriptionsToIncludeResourceGroups
13+
Scoped Subscription list
14+
.PARAMETER ResourceGroup
15+
ResourceGroup switch indicating desired scope condition
1016
.EXAMPLE
1117
> Get-AzOpsPolicyExemption -ScopeObject (New-AzOpsScope -Scope /providers/Microsoft.Management/managementGroups/contoso -StatePath $StatePath)
1218
Discover all custom policy exemptions deployed at Management Group scope
1319
#>
1420

15-
[OutputType([Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.Policy.PsPolicyExemption])]
21+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IPolicyExemption])]
1622
[CmdletBinding()]
1723
param (
1824
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
1925
[Object]
20-
$ScopeObject
26+
$ScopeObject,
27+
[Parameter(Mandatory = $false)]
28+
[object]
29+
$Subscription,
30+
[Parameter(Mandatory = $false)]
31+
[object]
32+
$SubscriptionsToIncludeResourceGroups,
33+
[Parameter(Mandatory = $false)]
34+
[bool]
35+
$ResourceGroup
2136
)
2237

2338
process {
2439
if ($ScopeObject.Type -notin 'resourceGroups', 'subscriptions', 'managementGroups') {
2540
return
2641
}
27-
28-
switch ($ScopeObject.Type) {
29-
managementGroups {
30-
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.ManagementGroup' -LogStringValues $ScopeObject.ManagementGroupDisplayName, $ScopeObject.ManagementGroup -Target $ScopeObject
42+
if ($ScopeObject.Type -eq 'managementGroups') {
43+
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.ManagementGroup' -LogStringValues $ScopeObject.ManagementGroupDisplayName, $ScopeObject.ManagementGroup -Target $ScopeObject
44+
if ((-not $SubscriptionsToIncludeResourceGroups) -or (-not $ResourceGroups)) {
45+
$query = "policyresources | where type == 'microsoft.authorization/policyexemptions' and resourceGroup == '' and subscriptionId == '' | order by ['id'] asc"
46+
Search-AzOpsAzGraph -ManagementGroupName $ScopeObject.Name -Query $query -ErrorAction Stop
3147
}
32-
subscriptions {
48+
}
49+
if ($Subscription) {
50+
if ($SubscriptionsToIncludeResourceGroups -and $ResourceGroup) {
3351
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.Subscription' -LogStringValues $ScopeObject.SubscriptionDisplayName, $ScopeObject.Subscription -Target $ScopeObject
52+
$query = "policyresources | where type == 'microsoft.authorization/policyexemptions' and resourceGroup != '' | order by ['id'] asc"
53+
Search-AzOpsAzGraph -Subscription $SubscriptionsToIncludeResourceGroups -Query $query -ErrorAction Stop
3454
}
35-
resourcegroups {
55+
elseif ($ResourceGroup) {
3656
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.ResourceGroup' -LogStringValues $ScopeObject.ResourceGroup -Target $ScopeObject
57+
$query = "policyresources | where type == 'microsoft.authorization/policyexemptions' and resourceGroup != '' | order by ['id'] asc"
58+
Search-AzOpsAzGraph -Subscription $Subscription -Query $query -ErrorAction Stop
3759
}
38-
}
39-
try {
40-
$parameters = @{
41-
Scope = $ScopeObject.Scope
60+
else {
61+
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.Subscription' -LogStringValues $ScopeObject.SubscriptionDisplayName, $ScopeObject.Subscription -Target $ScopeObject
62+
$query = "policyresources | where type == 'microsoft.authorization/policyexemptions' and resourceGroup == '' | order by ['id'] asc"
63+
Search-AzOpsAzGraph -Subscription $Subscription -Query $query -ErrorAction Stop
4264
}
43-
# Gather policyExemption with retry and backoff support from Invoke-AzOpsScriptBlock
44-
Invoke-AzOpsScriptBlock -ArgumentList $parameters -ScriptBlock {
45-
Get-AzPolicyExemption @parameters -WarningAction SilentlyContinue -ErrorAction Stop | Where-Object ResourceId -match $parameters.Scope
46-
} -RetryCount 3 -RetryWait 5 -RetryType Exponential -ErrorAction Stop
47-
}
48-
catch {
49-
Write-AzOpsMessage -LogLevel Warning -LogString 'Get-AzOpsPolicyExemption.Failed' -LogStringValues $ScopeObject.Scope
5065
}
5166
}
5267

src/internal/functions/Get-AzOpsPolicySetDefinition.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Discover all custom policyset definitions deployed at Management Group scope
1515
#>
1616

17-
[OutputType([Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.Policy.PsPolicySetDefinition])]
17+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Policy.Models.IPolicySetDefinition])]
1818
[CmdletBinding()]
1919
param (
2020
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]

src/internal/functions/Get-AzOpsResourceDefinition.ps1

+6-24
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,13 @@
152152
$script:AzOpsPartialRoot = $runspaceData.runspace_AzOpsPartialRoot
153153
$script:AzOpsResourceProvider = $runspaceData.runspace_AzOpsResourceProvider
154154
}
155-
# Process Privileged Identity Management resources, Policies and Roles at managementGroup scope
156-
if ((-not $using:SkipPim) -or (-not $using:SkipPolicy) -or (-not $using:SkipRole)) {
155+
# Process Privileged Identity Management resources and Roles at managementGroup scope
156+
if ((-not $using:SkipPim) -or (-not $using:SkipRole)) {
157157
& $azOps {
158158
$ScopeObject = New-AzOpsScope -Scope $managementgroup.id -StatePath $runspaceData.Statepath -ErrorAction Stop
159159
if (-not $using:SkipPim) {
160160
Get-AzOpsPim -ScopeObject $ScopeObject -StatePath $runspaceData.Statepath
161161
}
162-
if (-not $using:SkipPolicy) {
163-
$policyExemptions = Get-AzOpsPolicyExemption -ScopeObject $ScopeObject
164-
if ($policyExemptions) {
165-
$policyExemptions | ConvertTo-AzOpsState -StatePath $runspaceData.Statepath
166-
}
167-
}
168162
if (-not $using:SkipRole) {
169163
Get-AzOpsRole -ScopeObject $ScopeObject -StatePath $runspaceData.Statepath
170164
}
@@ -196,19 +190,13 @@
196190
$script:AzOpsPartialRoot = $runspaceData.runspace_AzOpsPartialRoot
197191
$script:AzOpsResourceProvider = $runspaceData.runspace_AzOpsResourceProvider
198192
}
199-
# Process Privileged Identity Management resources, Policies, Locks and Roles at subscription scope
200-
if ((-not $using:SkipPim) -or (-not $using:SkipPolicy) -or (-not $using:SkipLock) -or (-not $using:SkipRole)) {
193+
# Process Privileged Identity Management resources, Locks and Roles at subscription scope
194+
if ((-not $using:SkipPim) -or (-not $using:SkipLock) -or (-not $using:SkipRole)) {
201195
& $azOps {
202196
$scopeObject = New-AzOpsScope -Scope ($subscription.Type + '/' + $subscription.Id) -StatePath $runspaceData.Statepath -ErrorAction Stop
203197
if (-not $using:SkipPim) {
204198
Get-AzOpsPim -ScopeObject $scopeObject -StatePath $runspaceData.Statepath
205199
}
206-
if (-not $using:SkipPolicy) {
207-
$policyExemptions = Get-AzOpsPolicyExemption -ScopeObject $scopeObject
208-
if ($policyExemptions) {
209-
$policyExemptions | ConvertTo-AzOpsState -StatePath $runspaceData.Statepath
210-
}
211-
}
212200
if (-not $using:SkipLock) {
213201
Get-AzOpsResourceLock -ScopeObject $scopeObject -StatePath $runspaceData.Statepath
214202
}
@@ -264,8 +252,8 @@
264252
& $azOps {
265253
ConvertTo-AzOpsState -Resource $resourceGroup -StatePath $runspaceData.Statepath
266254
}
267-
# Process Privileged Identity Management resources, Policies, Locks and Roles at resource group scope
268-
if ((-not $using:SkipPim) -or (-not $using:SkipPolicy) -or (-not $using:SkipRole) -or (-not $using:SkipLock)) {
255+
# Process Privileged Identity Management resources, Locks and Roles at resource group scope
256+
if ((-not $using:SkipPim) -or (-not $using:SkipRole) -or (-not $using:SkipLock)) {
269257
& $azOps {
270258
$rgScopeObject = New-AzOpsScope -Scope $resourceGroup.id -StatePath $runspaceData.Statepath -ErrorAction Stop
271259
if (-not $using:SkipLock) {
@@ -274,12 +262,6 @@
274262
if (-not $using:SkipPim) {
275263
Get-AzOpsPim -ScopeObject $rgScopeObject -StatePath $runspaceData.Statepath
276264
}
277-
if (-not $using:SkipPolicy) {
278-
$policyExemptions = Get-AzOpsPolicyExemption -ScopeObject $rgScopeObject
279-
if ($policyExemptions) {
280-
$policyExemptions | ConvertTo-AzOpsState -StatePath $runspaceData.Statepath
281-
}
282-
}
283265
if (-not $using:SkipRole) {
284266
Get-AzOpsRole -ScopeObject $rgScopeObject -StatePath $runspaceData.Statepath
285267
}

0 commit comments

Comments
 (0)