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
7 changes: 4 additions & 3 deletions docs/wiki/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ The following configuration values can be modified within the `settings.json` fi
| 16 | SkipPolicy | Generate template files for Policy types |
| 17 | SkipResource | Generate template files for Resources within Resource Groups |
| 18 | SkipResourceGroup | Generate folder hierachy for all Resource Groups |
| 19 | SkipRole | Generate template files for Role types |
| 20 | State | Default top level folder name within the repository |
| 21 | SubscriptionsToIncludeResourceGroups | Generate folder hierachy for specific Resource Groups |
| 19 | SkipResourceType | Skip specific [Resource Types](https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/resource-providers-and-types) (only targets Resource Group scoped resources)|
| 20 | SkipRole | Generate template files for Role types |
| 21 | State | Default top level folder name within the repository |
| 22 | SubscriptionsToIncludeResourceGroups | Generate folder hierachy for specific Resource Groups |
| 23 | TemplateParameterFileSuffix | Default template file suffix |
| 24 | ThrottleLimit | |
1 change: 1 addition & 0 deletions src/internal/configurations/Core.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Set-PSFConfig -Module AzOps -Name Core.PartialMgDiscoveryRoot -Value @() -Initia
Set-PSFConfig -Module AzOps -Name Core.SkipPolicy -Value $false -Initialize -Validation bool -Description '-'
Set-PSFConfig -Module AzOps -Name Core.SkipResource -Value $true -Initialize -Validation bool -Description 'Global flag to indicate whether resource should be discovered or not. Requires SkipResourceGroup to be false.'
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'
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.'
Set-PSFConfig -Module AzOps -Name Core.SkipRole -Value $false -Initialize -Validation bool -Description '-'
Set-PSFConfig -Module AzOps -Name Core.State -Value (Join-Path $pwd -ChildPath "root") -Initialize -Validation string -Description 'Folder to store AzOpsState artefact'
Set-PSFConfig -Module AzOps -Name Core.SubscriptionsToIncludeResourceGroups -Value @('*') -Initialize -Validation stringarray -Description 'Requires SkipResourceGroup to be false. Subscription ID or Display Name that matches the filter. Powershell filter that matches with like operator is supported.'
Expand Down
20 changes: 16 additions & 4 deletions src/internal/functions/Get-AzOpsResourceDefinition.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
Skip discovery of resource groups.
.PARAMETER SkipResource
Skip discovery of resources inside resource groups.
.PARAMETER SkipResourceType
Skip discovery of specific resource types.
.PARAMETER ExportRawTemplate
Export generic templates without embedding them in the parameter block.
.PARAMETER StatePath
Expand Down Expand Up @@ -54,6 +56,9 @@
[switch]
$SkipResource = (Get-PSFConfigValue -FullName 'AzOps.Core.SkipResource'),

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

[switch]
$ExportRawTemplate = (Get-PSFConfigValue -FullName 'AzOps.Core.ExportRawTemplate'),

Expand Down Expand Up @@ -105,6 +110,9 @@
[switch]
$SkipResource,

[string[]]
$SkipResourceType,

[string]
$StatePath,

Expand Down Expand Up @@ -145,7 +153,7 @@
ODataQuery = $OdataFilter
ExpandProperties = $true
}
Get-AzResource @paramGetAzResource | ForEach-Object {
Get-AzResource @paramGetAzResource | Where-Object {$_.Type -notin $SkipResourceType} | ForEach-Object {
New-AzOpsScope -Scope $_.ResourceId
} | ConvertFrom-TypeResource -StatePath $StatePath -ExportRawTemplate:$ExportRawTemplate
}
Expand All @@ -172,6 +180,9 @@
[switch]
$SkipResource,

[string[]]
$SkipResourceType,

[string]
$ODataFilter )
begin {
Expand Down Expand Up @@ -220,6 +231,7 @@
ScopeObject = $ScopeObject
ODataFilter = $ODataFilter
SkipResource = $SkipResource
SkipResourceType = $SkipResourceType
MaxRetryCount = $maxRetryCount
BackoffMultiplier = $backoffMultiplier
ExportRawTemplate = $ExportRawTemplate
Expand Down Expand Up @@ -284,7 +296,7 @@
}

# Loop through resources and convert them to AzOpsState
foreach ($resource in $resources) {
foreach ($resource in ($resources | Where-Object {$_.Type -notin $runspaceData.SkipResourceType})) {
# Convert resources to AzOpsState
Write-PSFMessage @msgCommon -String 'Get-AzOpsResourceDefinition.SubScription.Processing.Resource' -StringValues $resource.Name, $resourceGroup.ResourceGroupName -Target $resource
& $azOps { ConvertTo-AzOpsState -Resource $resource -ExportRawTemplate:$runspaceData.ExportRawTemplate -StatePath $runspaceData.Statepath }
Expand Down Expand Up @@ -392,8 +404,8 @@

switch ($scopeObject.Type) {
resource { ConvertFrom-TypeResource -ScopeObject $scopeObject -StatePath $StatePath -ExportRawTemplate:$ExportRawTemplate }
resourcegroups { ConvertFrom-TypeResourceGroup -ScopeObject $scopeObject -StatePath $StatePath -ExportRawTemplate:$ExportRawTemplate -Context $context -SkipResource:$SkipResource -OdataFilter $odataFilter }
subscriptions { ConvertFrom-TypeSubscription -ScopeObject $scopeObject -StatePath $StatePath -ExportRawTemplate:$ExportRawTemplate -Context $context -SkipResourceGroup:$SkipResourceGroup -SkipResource:$SkipResource -ODataFilter $odataFilter }
resourcegroups { ConvertFrom-TypeResourceGroup -ScopeObject $scopeObject -StatePath $StatePath -ExportRawTemplate:$ExportRawTemplate -Context $context -SkipResource:$SkipResource -SkipResourceType:$SkipResourceType -OdataFilter $odataFilter }
subscriptions { ConvertFrom-TypeSubscription -ScopeObject $scopeObject -StatePath $StatePath -ExportRawTemplate:$ExportRawTemplate -Context $context -SkipResourceGroup:$SkipResourceGroup -SkipResource:$SkipResource -SkipResourceType:$SkipResourceType -ODataFilter $odataFilter }
managementGroups { ConvertFrom-TypeManagementGroup -ScopeObject $scopeObject -StatePath $StatePath -ExportRawTemplate:$ExportRawTemplate -SkipPolicy:$SkipPolicy -SkipRole:$SkipRole -SkipResourceGroup:$SkipResourceGroup -SkipResource:$SkipResource }
}

Expand Down