Skip to content

Commit 265d41a

Browse files
authored
Adding Pull Retry Logic with Exclusion of Subscription Resources and SkipSubscription setting. (#938)
* Update * Update * Update * Update * Update * Update * Update * Update * Update * Add SkipSubscription Test * Update * Update * Update
1 parent 8e4d137 commit 265d41a

File tree

10 files changed

+517
-122
lines changed

10 files changed

+517
-122
lines changed

docs/wiki/Settings.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ The following configuration values can be modified within the `settings.json` fi
3434
| 22 | SkipResourceGroup | Do not include Resource Groups in pull | `"Core.SkipResourceGroup": false` |
3535
| 23 | SkipResourceType | Skip specific [Resource Types](https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/resource-providers-and-types) (only targets Resource Group scoped resources) | `"Core.SkipResourceType": ["Microsoft.VSOnline/plans"]` |
3636
| 24 | SkipRole | Do not include Role types in pull | `"Core.SkipRole": false` |
37-
| 25 | State | Folder to store AzOpsState artefact, defaults to `root` | `"Core.State: "/root"` |
38-
| 26 | SubscriptionsToIncludeChildResource | Filter which Subscription IDs should include child resources in pull | `"Core.SubscriptionsToIncludeChildResource": ["*"]` |
39-
| 27 | SubscriptionsToIncludeResourceGroups | Filter which Subscription IDs should include Resource Groups in pull [Logic Updated in v2.0.0](https://github.com/Azure/AzOps/releases/tag/2.0.0) | `"Core.SubscriptionsToIncludeResourceGroups": ["*"]` |
40-
| 28 | TemplateParameterFileSuffix | Default template file suffix. *Not recommended to change* | `"Core.TemplateParameterFileSuffix": ".json"` |
41-
| 29 | AllowMultipleTemplateParameterFiles | Control multiple parameter file behaviour. *Not recommended to change* | `"Core.AllowMultipleTemplateParameterFiles": false` |
42-
| 30 | DeployAllMultipleTemplateParameterFiles | Control base template deployment behaviour with changes and un-changed multiple corresponding parameter files. | `"Core.DeployAllMultipleTemplateParameterFiles": false` |
43-
| 31 | MultipleTemplateParameterFileSuffix | Multiple parameter file suffix identifier. *Example mytemplate.x1.bicepparam* | `"Core.MultipleTemplateParameterFileSuffix": ".x"` |
44-
| 32 | ParallelDeployMultipleTemplateParameterFiles | Control parallel deployment of MultipleTemplateParameterFiles behaviour | `"Core.ParallelDeployMultipleTemplateParameterFiles": false` |
45-
| 33 | ThrottleLimit | Value declaring number of parallel threads. [Read more](https://github.com/azure/azops/wiki/performance-considerations) | `"Core.ThrottleLimit": 5` |
46-
| 34 | WhatifExcludedChangeTypes | Exclude specific change types from WhatIf operations | `"Core.WhatifExcludedChangeTypes": ["NoChange","Ignore"]` |
37+
| 25 | SkipSubscription | Filter which Subscription IDs should be excluded from pull | `"Core.SkipSubscription": ["*"]` |
38+
| 26 | State | Folder to store AzOpsState artefact, defaults to `root` | `"Core.State: "/root"` |
39+
| 27 | SubscriptionsToIncludeChildResource | Filter which Subscription IDs should include child resources in pull | `"Core.SubscriptionsToIncludeChildResource": ["*"]` |
40+
| 28 | SubscriptionsToIncludeResourceGroups | Filter which Subscription IDs should include Resource Groups in pull [Logic Updated in v2.0.0](https://github.com/Azure/AzOps/releases/tag/2.0.0) | `"Core.SubscriptionsToIncludeResourceGroups": ["*"]` |
41+
| 29 | TemplateParameterFileSuffix | Default template file suffix. *Not recommended to change* | `"Core.TemplateParameterFileSuffix": ".json"` |
42+
| 30 | AllowMultipleTemplateParameterFiles | Control multiple parameter file behaviour. *Not recommended to change* | `"Core.AllowMultipleTemplateParameterFiles": false` |
43+
| 31 | DeployAllMultipleTemplateParameterFiles | Control base template deployment behaviour with changes and un-changed multiple corresponding parameter files. | `"Core.DeployAllMultipleTemplateParameterFiles": false` |
44+
| 32 | MultipleTemplateParameterFileSuffix | Multiple parameter file suffix identifier. *Example mytemplate.x1.bicepparam* | `"Core.MultipleTemplateParameterFileSuffix": ".x"` |
45+
| 33 | ParallelDeployMultipleTemplateParameterFiles | Control parallel deployment of MultipleTemplateParameterFiles behaviour | `"Core.ParallelDeployMultipleTemplateParameterFiles": false` |
46+
| 34 | ThrottleLimit | Value declaring number of parallel threads. [Read more](https://github.com/azure/azops/wiki/performance-considerations) | `"Core.ThrottleLimit": 5` |
47+
| 35 | WhatifExcludedChangeTypes | Exclude specific change types from WhatIf operations | `"Core.WhatifExcludedChangeTypes": ["NoChange","Ignore"]` |
4748

4849
## Workflow / Pipeline Settings
4950

src/AzOps.psd1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: Customer Architecture Team (CAT)
55
#
6-
# Generated on: 09/16/2025
6+
# Generated on: 11/27/2025
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.13.406'; },
55-
@{ModuleName = 'Az.Accounts'; RequiredVersion = '5.3.0'; },
54+
RequiredModules = @(@{ModuleName = 'PSFramework'; RequiredVersion = '1.13.419'; },
55+
@{ModuleName = 'Az.Accounts'; RequiredVersion = '5.3.1'; },
5656
@{ModuleName = 'Az.Billing'; RequiredVersion = '2.2.0'; },
5757
@{ModuleName = 'Az.ResourceGraph'; RequiredVersion = '1.2.1'; },
58-
@{ModuleName = 'Az.Resources'; RequiredVersion = '8.1.0'; })
58+
@{ModuleName = 'Az.Resources'; RequiredVersion = '9.0.0'; })
5959

6060
# Assemblies that must be loaded prior to importing this module
6161
# RequiredAssemblies = @()

src/internal/configurations/Core.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Set-PSFConfig -Module AzOps -Name Core.SkipResource -Value $true -Initialize -Va
2525
Set-PSFConfig -Module AzOps -Name Core.SkipResourceGroup -Value $false -Initialize -Validation bool -Description 'Global flag to indicate whether resource group should be discovered or not'
2626
Set-PSFConfig -Module AzOps -Name Core.SkipResourceType -Value @('Microsoft.VSOnline/plans', 'Microsoft.PowerPlatform/accounts', 'Microsoft.PowerPlatform/enterprisePolicies') -Initialize -Validation stringarray -Description 'Global flag to skip discovery of specific Resource types.'
2727
Set-PSFConfig -Module AzOps -Name Core.SkipRole -Value $false -Initialize -Validation bool -Description '-'
28+
Set-PSFConfig -Module AzOps -Name Core.SkipSubscription -Value @('*') -Initialize -Validation stringarray -Description 'Skip Subscription ID that matches the filter.'
2829
Set-PSFConfig -Module AzOps -Name Core.State -Value (Join-Path $pwd -ChildPath "root") -Initialize -Validation string -Description 'Folder to store AzOpsState artefact'
2930
Set-PSFConfig -Module AzOps -Name Core.SubscriptionsToIncludeChildResource -Value @('*') -Initialize -Validation stringarray -Description 'Requires SkipResourceGroup, SkipResource and SkipChildResource to be false. Subscription ID that matches the filter.'
3031
Set-PSFConfig -Module AzOps -Name Core.SubscriptionsToIncludeResourceGroups -Value @('*') -Initialize -Validation stringarray -Description 'Requires SkipResourceGroup to be false. Subscription ID that matches the filter.'

src/internal/functions/Get-AzOpsNestedSubscription.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
Create a list of subscriptionId's nested at ManagementGroup Scope
55
.PARAMETER Scope
66
ManagementGroup Name
7+
.PARAMETER SkipSubscription
8+
Filter which Subscription IDs should be excluded from pull.
79
.EXAMPLE
810
> Get-AzOpsNestedSubscription -Scope 5663f39e-feb1-4303-a1f9-cf20b702de61
911
Discover subscriptions at Management Group scope and below
@@ -13,15 +15,18 @@
1315
param (
1416
[Parameter(Mandatory = $false)]
1517
[string]
16-
$Scope
18+
$Scope,
19+
20+
[string[]]
21+
$SkipSubscription = (Get-PSFConfigValue -FullName 'AzOps.Core.SkipSubscription')
1722
)
1823

1924
process {
2025
$children = ($script:AzOpsAzManagementGroup | Where-Object {$_.Name -eq $Scope}).Children
2126
if ($children) {
2227
$subscriptionIds = @()
2328
foreach ($child in $children) {
24-
if (($child.Type -eq '/subscriptions') -and ($script:AzOpsSubscriptions.id -contains $child.Id)) {
29+
if (($child.Type -eq '/subscriptions') -and ($script:AzOpsSubscriptions.id -contains $child.Id) -and ($child.Name -notin $SkipSubscription)) {
2530
$subscriptionIds += [PSCustomObject] @{
2631
Name = $child.DisplayName
2732
Id = $child.Name

src/internal/functions/Get-AzOpsPolicyExemption.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,17 @@
4848
}
4949
if ($Subscription) {
5050
if ($SubscriptionsToIncludeResourceGroups -and $ResourceGroup) {
51-
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.Subscription' -LogStringValues $ScopeObject.SubscriptionDisplayName, $ScopeObject.Subscription -Target $ScopeObject
51+
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.Subscription' -LogStringValues $SubscriptionsToIncludeResourceGroups.count -Target $ScopeObject
5252
$query = "policyresources | where type == 'microsoft.authorization/policyexemptions' and resourceGroup != '' | order by ['id'] asc"
5353
Search-AzOpsAzGraph -Subscription $SubscriptionsToIncludeResourceGroups -Query $query -ErrorAction Stop
5454
}
5555
elseif ($ResourceGroup) {
56-
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.ResourceGroup' -LogStringValues $ScopeObject.ResourceGroup -Target $ScopeObject
56+
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.ResourceGroup' -LogStringValues $Subscription.count -Target $ScopeObject
5757
$query = "policyresources | where type == 'microsoft.authorization/policyexemptions' and resourceGroup != '' | order by ['id'] asc"
5858
Search-AzOpsAzGraph -Subscription $Subscription -Query $query -ErrorAction Stop
5959
}
6060
else {
61-
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.Subscription' -LogStringValues $ScopeObject.SubscriptionDisplayName, $ScopeObject.Subscription -Target $ScopeObject
61+
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsPolicyExemption.Subscription' -LogStringValues $Subscription.count -Target $ScopeObject
6262
$query = "policyresources | where type == 'microsoft.authorization/policyexemptions' and resourceGroup == '' | order by ['id'] asc"
6363
Search-AzOpsAzGraph -Subscription $Subscription -Query $query -ErrorAction Stop
6464
}

0 commit comments

Comments
 (0)