RuiRomano / pbimonitor

MIT License
220 stars 83 forks source link

Timers not running #36

Open brunoalvesdesousa opened 1 year ago

brunoalvesdesousa commented 1 year ago

the following happens when invoking any of the timers:

2023-06-29T10:46:17Z   [Information]   Executing 'Functions.AuditsTimer' (Reason='This function was programmatically called via the host APIs.', Id=2c6369ab-d8a9-4746-9212-381d303d65e1)
2023-06-29T10:46:17Z   [Verbose]   Sending invocation id: '2c6369ab-d8a9-4746-9212-381d303d65e1
2023-06-29T10:46:17Z   [Verbose]   Posting invocation id:2c6369ab-d8a9-4746-9212-381d303d65e1 on workerId:b1ee0548-2130-46aa-94d3-d8e48d96a92a
2023-06-29T10:46:18Z   [Information]   INFORMATION: PBIMonitor - Fetch Activity Started: 06/29/2023 10:46:17
2023-06-29T10:46:18Z   [Information]   INFORMATION: Building PBIMonitor Config from Azure Function Configuration
2023-06-29T10:46:18Z   [Information]   INFORMATION: AppDataPath: C:\home\data\pbimonitor
2023-06-29T10:46:18Z   [Information]   INFORMATION: ScriptsPath: C:\home\site\wwwroot\Scripts
2023-06-29T10:46:18Z   [Information]   INFORMATION: OutputPath: C:\local\Temp\PBIMonitorData\87508303bdbb40dba1b3934e70d00585
2023-06-29T10:46:18Z   [Information]   INFORMATION: Starting Power BI Activity Fetch
2023-06-29T10:46:18Z   [Information]   INFORMATION: Since: 2023-05-30T00:00:00
2023-06-29T10:46:18Z   [Information]   INFORMATION: OutputBatchCount: 5000
2023-06-29T10:46:18Z   [Information]   INFORMATION: Ellapsed: 0.005944s
2023-06-29T10:46:18Z   [Information]   INFORMATION: Getting OAuth Token
2023-06-29T10:46:18Z   [Information]   OUTPUT: 
2023-06-29T10:46:18Z   [Information]   OUTPUT:    HistoryId: 1
2023-06-29T10:46:18Z   [Information]   OUTPUT: 
2023-06-29T10:46:18Z   [Information]   OUTPUT: Message        : Cannot bind argument to parameter 'String' because it is an empty string.
2023-06-29T10:46:18Z   [Information]   OUTPUT: StackTrace     :    at System.Management.Automation.CmdletParameterBinderController.BindValueFromPipeline(PSObject inputToOperateOn, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
2023-06-29T10:46:18Z   [Information]   OUTPUT:                     at System.Management.Automation.CmdletParameterBinderController.BindUnboundParametersForBindingStateInParameterSet(PSObject inputToOperateOn, CurrentlyBinding currentlyBinding, UInt32 validParameterSets)
2023-06-29T10:46:18Z   [Information]   OUTPUT:                     at System.Management.Automation.CmdletParameterBinderController.BindUnboundParametersForBindingState(PSObject inputToOperateOn, CurrentlyBinding currentlyBinding, UInt32 validParameterSets)
2023-06-29T10:46:18Z   [Information]   OUTPUT:                     at System.Management.Automation.CmdletParameterBinderController.BindPipelineParametersPrivate(PSObject inputToOperateOn)
2023-06-29T10:46:18Z   [Information]   OUTPUT:                     at System.Management.Automation.CmdletParameterBinderController.BindPipelineParameters(PSObject inputToOperateOn)
2023-06-29T10:46:18Z   [Information]   OUTPUT:                     at System.Management.Automation.CommandProcessor.ProcessInputPipelineObject(Object inputObject)
2023-06-29T10:46:18Z   [Information]   OUTPUT:                     at System.Management.Automation.CommandProcessor.Read()
2023-06-29T10:46:18Z   [Information]   OUTPUT: Exception      : System.Management.Automation.ParameterBindingValidationException
2023-06-29T10:46:18Z   [Information]   OUTPUT: InvocationInfo : {ConvertTo-SecureString}
2023-06-29T10:46:18Z   [Information]   OUTPUT: Line           :         $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $config.ServicePrincipal.AppId, ($config.ServicePrincipal.AppSecret | ConvertTo-SecureString -AsPlainText -Force)
2023-06-29T10:46:18Z   [Information]   OUTPUT:                  
2023-06-29T10:46:18Z   [Information]   OUTPUT: Position       : At C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1:65 char:170
2023-06-29T10:46:18Z   [Information]   OUTPUT:                  + … vicePrincipal.AppSecret | ConvertTo-SecureString -AsPlainText -Force)
2023-06-29T10:46:18Z   [Information]   OUTPUT:                  +                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2023-06-29T10:46:18Z   [Information]   OUTPUT: HistoryId      : 1
2023-06-29T10:46:18Z   [Information]   OUTPUT: 
2023-06-29T10:46:18Z   [Error]   EXCEPTION: Cannot bind argument to parameter 'String' because it is an empty string.

Exception             : 
    Type              : System.Management.Automation.ParameterBindingValidationException
    Message           : Cannot bind argument to parameter 'String' because it is an empty string.
    ParameterName     : String
    ParameterType     : string
    TypeSpecified     : string
    ErrorId           : ParameterArgumentValidationErrorEmptyStringNotAllowed
    Line              : 65
    Offset            : 170
    CommandInvocation : 
        MyCommand        : ConvertTo-SecureString
        BoundParameters  : 
            Comparer : System.OrdinalIgnoreCaseComparer
            Count    : 2
            Keys     : 
                Length : 11

                Length : 5
            Values   : 
                IsPresent : True

                IsPresent : True
            SyncRoot : 
                Comparer : System.OrdinalIgnoreCaseComparer
                Count    : 2
                Keys     : 
                    Length : 11

                    Length : 5
                Values   : 
                    IsPresent : True

                    IsPresent : True
                SyncRoot : 
                    Comparer : System.OrdinalIgnoreCaseComparer
                    Count    : 2
                    Keys     : 
                        Length : 11

                        Length : 5
                    Values   : 
                        IsPresent : True

                        IsPresent : True
                    SyncRoot : 
                        Comparer : System.OrdinalIgnoreCaseComparer
                        Count    : 2
                        Keys     : 
                            Length : 11

                            Length : 5
                        Values   : 
                            IsPresent : True

                            IsPresent : True
                        SyncRoot : 
                            Comparer : System.OrdinalIgnoreCaseComparer
                            Count    : 2
                            Keys     : 
                                Length : 11

                                Length : 5
                            Values   : 
                                IsPresent : True

                                IsPresent : True
                            SyncRoot : 
                                Comparer : System.OrdinalIgnoreCaseComparer
                                Count    : 2
                                Keys     : 
                                    Length : 11

                                    Length : 5
                                Values   : 
                                    IsPresent : True

                                    IsPresent : True
                                SyncRoot : 
                                    Comparer : System.OrdinalIgnoreCaseComparer
                                    Count    : 2
                                    Keys     : …
                                    Values   : …
                                    SyncRoot : …
        ScriptLineNumber : 65
        OffsetInLine     : 170
        HistoryId        : 1
        ScriptName       : C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1
        Line             : $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $config.ServicePrincipal.AppId, ($config.ServicePrincipal.AppSecret | ConvertTo-SecureString -AsPlainText -Force)

        PositionMessage  : At C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1:65 char:170
                           + … vicePrincipal.AppSecret | ConvertTo-SecureString -AsPlainText -Force)
                           +                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        PSScriptRoot     : C:\home\site\wwwroot\Scripts
        PSCommandPath    : C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1
        InvocationName   : ConvertTo-SecureString
        PipelineLength   : 1
        PipelinePosition : 1
        ExpectingInput   : True
        CommandOrigin    : Internal
    ErrorRecord       : 
        Exception             : 
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Cannot bind argument to parameter 'String' because it is an empty string.
            HResult : -2146233087
        CategoryInfo          : InvalidData: (:String) [ConvertTo-SecureString], ParentContainsErrorRecordException
        FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand
        InvocationInfo        : 
            MyCommand        : ConvertTo-SecureString
            ScriptLineNumber : 65
            OffsetInLine     : 170
            HistoryId        : 1
            ScriptName       : C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1
            Line             : $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $config.ServicePrincipal.AppId, ($config.ServicePrincipal.AppSecret | ConvertTo-SecureString -AsPlainText -Force)

            PositionMessage  : At C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1:65 char:170
                               + … vicePrincipal.AppSecret | ConvertTo-SecureString -AsPlainText -Force)
                               +                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            PSScriptRoot     : C:\home\site\wwwroot\Scripts
            PSCommandPath    : C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1
            CommandOrigin    : Internal
        ScriptStackTrace      : at <ScriptBlock>, C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1: line 65
                                at <ScriptBlock>, C:\home\site\wwwroot\AuditsTimer\run.ps1: line 31
    TargetSite        : 
        Name          : BindValueFromPipeline
        DeclaringType : System.Management.Automation.CmdletParameterBinderController, System.Management.Automation, Version=7.2.11.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Source            : System.Management.Automation
    HResult           : -2146233087
    StackTrace        : 
   at System.Management.Automation.CmdletParameterBinderController.BindValueFromPipeline(PSObject inputToOperateOn, MergedCompiledCommandParameter parameter, ParameterBindingFlags flags)
   at System.Management.Automation.CmdletParameterBinderController.BindUnboundParametersForBindingStateInParameterSet(PSObject inputToOperateOn, CurrentlyBinding currentlyBinding, UInt32 validParameterSets)
   at System.Management.Automation.CmdletParameterBinderController.BindUnboundParametersForBindingState(PSObject inputToOperateOn, CurrentlyBinding currentlyBinding, UInt32 validParameterSets)
   at System.Management.Automation.CmdletParameterBinderController.BindPipelineParametersPrivate(PSObject inputToOperateOn)
   at System.Management.Automation.CmdletParameterBinderController.BindPipelineParameters(PSObject inputToOperateOn)
   at System.Management.Automation.CommandProcessor.ProcessInputPipelineObject(Object inputObject)
   at System.Management.Automation.CommandProcessor.Read()
CategoryInfo          : InvalidData: (:String) [ConvertTo-SecureString], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.ConvertToSecureStringCommand
InvocationInfo        : 
    MyCommand        : ConvertTo-SecureString
    ScriptLineNumber : 65
    OffsetInLine     : 170
    HistoryId        : 1
    ScriptName       : C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1
    Line             : $credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $config.ServicePrincipal.AppId, ($config.ServicePrincipal.AppSecret | ConvertTo-SecureString -AsPlainText -Force)

    PositionMessage  : At C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1:65 char:170
                       + … vicePrincipal.AppSecret | ConvertTo-SecureString -AsPlainText -Force)
                       +                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : C:\home\site\wwwroot\Scripts
    PSCommandPath    : C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, C:\home\site\wwwroot\Scripts\Fetch - Activity.ps1: line 65
                        at <ScriptBlock>, C:\home\site\wwwroot\AuditsTimer\run.ps1: line 31

2023-06-29T10:46:18Z   [Error]   Executed 'Functions.AuditsTimer' (Failed, Id=2c6369ab-d8a9-4746-9212-381d303d65e1, Duration=335ms)

Any help greatly appreciated!

image image

lukebrandt commented 1 year ago

It looks like the authentication isn't able to complete due to ConvertTo-SecureString being empty. Is the AppSecret variable set?

brunoalvesdesousa commented 1 year ago

The AppSecret variable is set yes