manifests/collectors/Containers/ContainerAppEnv.psd1

#
# GENERATED by scripts/ConvertTo-ScoutCollectorDefinition.ps1 from Modules/Public/InventoryModules/Containers/ContainerAppEnv.ps1 (AB#5660).
# Field expressions are copied verbatim from the original collector and evaluate in an
# equivalent scope -- see docs/design/decisions/declarative-collectors.md.
# Review before trusting; regenerate rather than hand-patch if the source collector changes.
#
@{
    ResourceTypes = @(
        'microsoft.app/managedenvironments'
    )

    ResourceTypeMatching = 'Grouped'

    AdditionalFilter = $null

    FilterPreamble = ''

    RowLoopVariable = '1'

    SetupPreamble = @'
$CONTAINERENV = $Resources | Where-Object {$_.TYPE -eq 'microsoft.app/managedenvironments'}
        $CONTAINER = $Resources | Where-Object {$_.TYPE -eq 'microsoft.app/containerapps'}
'@


    SetupVariables = @(
        'CONTAINERENV'
        'CONTAINER'
    )

    Preamble = @'
$ResUCount = 1
                # An EMPTY $sub1 -- subscription outside the requested scope -- is not $null, and
                # `.Name` on it throws under StrictMode (AB#5671).
                $sub1 = $SUB | Where-Object { $_.id -eq $1.subscriptionId }
                # The else arm is $null, NOT '': with StrictMode off $sub1.Name on an unmatched ($null)
                # $sub1 evaluated to $null, and the ~110 collectors that still read $sub1.Name directly
                # emit $null here. '' was a silent behaviour change -- the declarative equivalence proof
                # caught it on 11 collectors, and it would have been invisible on the rest (AB#5659).
                $SubscriptionName = if ($sub1) { @($sub1)[0].Name } else { $null }
                $data = $1.PROPERTIES
                $Retired = $Retirements | Where-Object { $_.id -eq $1.id }
                if ($Retired)
                    {
                        $RetiredFeature = foreach ($Retire in $Retired)
                            {
                                $RetiredServiceID = $Unsupported | Where-Object {$_.Id -eq $Retired.ServiceID}
                                $tmp0 = [pscustomobject]@{
                                        'RetiredFeature' = $RetiredServiceID.RetiringFeature
                                        'RetiredDate' = $RetiredServiceID.RetirementDate
                                    }
                                $tmp0
                            }
                        $RetiringFeature = if (@($RetiredFeature.RetiredFeature).count -gt 1) { $RetiredFeature.RetiredFeature | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredFeature}
                        $RetiringFeature = [string]$RetiringFeature
                        $RetiringFeature = if ($RetiringFeature -like '* ,*') { $RetiringFeature -replace ".$" }else { $RetiringFeature }
 
                        $RetiringDate = if (@($RetiredFeature.RetiredDate).count -gt 1) { $RetiredFeature.RetiredDate | ForEach-Object { $_ + ' ,' } }else { $RetiredFeature.RetiredDate}
                        $RetiringDate = [string]$RetiringDate
                        $RetiringDate = if ($RetiringDate -like '* ,*') { $RetiringDate -replace ".$" }else { $RetiringDate }
                    }
                else
                    {
                        $RetiringFeature = $null
                        $RetiringDate = $null
                    }
                # An untagged resource's Resource Graph row OMITS `tags`; the historic '0' sentinel
                # existed only to run the loop once for that case, and `'0'.Name` throws under
                # StrictMode. An empty tag object does the same job and emits the identical row.
                $RowTags = Get-AZSCSafeProperty -InputObject $1 -Path 'tags'
                $TagProps = if ($null -ne $RowTags) { $RowTags.psobject.properties } else { $null }
                $Tags = if(![string]::IsNullOrEmpty($TagProps)){$TagProps}else{[pscustomobject]@{ Name = $null; Value = $null }}
                $Apps = @($CONTAINER | Where-Object { (Get-AZSCSafeProperty -InputObject $_ -Path 'properties.environmentId') -eq $1.id }).count
'@


    AdditionalRowLoops = @(
        @{
            Variable = '2'
            Source = '(Get-AZSCSafeProperty -InputObject $data -Path ''workloadProfiles'')'
            Preamble = ''
        }
    )

    TagLoop = @{
        Variable = 'Tag'
        Source = '$Tags'
        Preamble = ''
    }

    Fields = @(
        @{
            Name = 'ID'
            Expression = '$1.id'
        }
        @{
            Name = 'Subscription'
            Expression = '$SubscriptionName'
        }
        @{
            Name = 'Resource Group'
            Expression = '$1.RESOURCEGROUP'
        }
        @{
            Name = 'Name'
            Expression = '$1.NAME'
        }
        @{
            Name = 'Location'
            Expression = '$1.LOCATION'
        }
        @{
            Name = 'Retiring Feature'
            Expression = '$RetiringFeature'
        }
        @{
            Name = 'Retiring Date'
            Expression = '$RetiringDate'
        }
        @{
            Name = 'Public Access'
            Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''publicNetworkAccess'')'
        }
        @{
            Name = 'Zone Redundant'
            Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''zoneRedundant'')'
        }
        @{
            Name = 'Static IP'
            Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''staticIp'')'
        }
        @{
            Name = 'KEDA version'
            Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''kedaconfiguration.Version'')'
        }
        @{
            Name = 'Dapr version'
            Expression = '(Get-AZSCSafeProperty -InputObject $data -Path ''daprconfiguration.Version'')'
        }
        @{
            Name = 'Workload Profile'
            Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''name'')'
        }
        @{
            Name = 'Workload Profile Type'
            Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''workloadProfileType'')'
        }
        @{
            Name = 'Workload Profile Min'
            Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''minimumCount'')'
        }
        @{
            Name = 'Workload Profile Max'
            Expression = '(Get-AZSCSafeProperty -InputObject $2 -Path ''maximumCount'')'
        }
        @{
            Name = 'Resource U'
            Expression = '$ResUCount'
        }
        @{
            Name = 'Tag Name'
            Expression = '[string]$Tag.Name'
        }
        @{
            Name = 'Tag Value'
            Expression = '[string]$Tag.Value'
        }
    )

    Export = @{
        WorksheetName = 'Container App Env'
        TableNamePrefix = 'ContEnvTb_'
        Columns = @(
            'Subscription'
            'Resource Group'
            'Name'
            'Location'
            'Retiring Feature'
            'Retiring Date'
            'Public Access'
            'Zone Redundant'
            'Static IP'
            'KEDA version'
            'Dapr version'
            'Workload Profile'
            'Workload Profile Type'
            'Workload Profile Min'
            'Workload Profile Max'
            'Resource U'
        )
        TagColumns = @(
            'Tag Name'
            'Tag Value'
        )
        TagColumnsBefore = 'Resource U'
        NumberFormat = '0'
        ConditionalText = @(
            'New-ConditionalText -Range E2:E100 -ConditionalType ContainsText'
            'New-ConditionalText Enabled -Range G:G -ConditionalType ContainsText'
            'New-ConditionalText False -Range H:H -ConditionalType ContainsText'
            'New-ConditionalText Consumption -Range M:M -ConditionalType ContainsText'
        )
    }

    SourceCollector = 'Modules/Public/InventoryModules/Containers/ContainerAppEnv.ps1'
}