Pages

Tuesday, October 18, 2022

Troubleshooting traffic blocked by Azure Front Door WAF Policy in Prevention mode

I recently had to troubleshoot an issue with an Azure Front Door WAF policy we had just changed from Detection to Prevention and thought I’d share some steps I used to troubleshoot and have this blog post for me to reference in the future as I’m bound to forget some of the steps.

Before you begin, have a look at the following Microsoft documentation to understand how to use Log Analytics to review WAF logs in a Log Analytics workspace:

Use Log Analytics to examine Application Gateway Web Application Firewall (WAF) Logs
https://learn.microsoft.com/en-us/azure/application-gateway/log-analytics

With that, let’s have a look at the process I went through.

Scenario

The developer notified me after the Front Door WAF Policy was switched from Prevention from Detection:

image

To troubleshoot, we used a browser’s Developer Tools to review the Network traffic and noticed the following error:

Request Method: Post
Status Code: 403
Referrer Policy: strict-origin-when-cross-origin

image

The above error was thrown when we opened up the website and navigated to sit.domain.com that presented a login page, entered our credentials into the form, clicked login, which would then send us to sitapp.domain.com. Clicking on the login button did not do anything as we would receive the 403 error as shown above.

Below is a screenshot of the log showing the origin and referrer URL, which is the login site we tried to log into:

image

Troubleshooting 

The first thought I had was that the referrer policy did not allow sit.domain.com to send a successful login to sitapp.domain.com so what we needed to do was whitelist the domain but this actually the wasn’t the case when we look into the logs.

There are no custom rules configured so we needed to determine which one of the managed rules has blocked the traffic:

image

In order to troubleshoot, Diagnostics must be turned on to capture the WebApplicationFirewall logs:

image

Verify that you are sending the FrontDoor WebApplicationFirewall Log to a log analytics workspace as shown here:

image

Once logging is turned on, wait 10 to 15 minutes for the log capturing to begin then proceed to replicate the issue. Note that you should see AzureDiagnostics displayed when logging has come into effect:

image

We should see entries with the following query when the WAF logs are captured:

AzureDiagnostics
| where Category == "FrontDoorWebApplicationFirewallLog"

image

Use the following query to retrieve all the entries representing blocks by a WAF rule:

AzureDiagnostics
| where action_s == "Block"

**Note that Block is case sensitive so “block” will not return any results.

image

Since we know have the information we collected from the browser network trace, we can use the information in there to look for the entry representing the block we’re experiencing. The values I usually use are requestUri_s or host_s but note that when using the requestUri_s, the URL will need to have a colon and port number after the domain as shown in the screenshot below:

https://sitapp.domain.com:443/webapi/api/account/login

image

Here is an example of adding the requestUri_s in the query:

AzureDiagnostics

| where action_s == "Block" and requestUri_s == https://sitapp.domain.com:443/webapi/api/account/login

With the entry located, review the ruleName_s value and note the ending number:

image

In this example, the rule that is blocking the traffic is 949110. However, this may not be locatable in the Managed rules of the WAF policy:

image

Although this is the rule that results in the traffic being blocked, it could be triggered by another rule. To determine the other related rules, we can locate the trackingReference_s value to look up the other logs related to this:

image

Use the following query to retrieve the entries:

AzureDiagnostics

| where trackingReference_s contains "0viJPYwAAAAD2qxqM/l3+QJ3xvYLEO0hYQ0hJMzBFREdFMDUxMwA0MzRlN2MwNC02M2NmLTRjMjMtYjFhOS00NDNjYmViZTJmNTg="

image

Expand the results and you should see another rule with the number 200002 that contains the same trackingReference_s as shown in the screenshot below:

image

Scrolling further down in the log will display more details about the reason why the traffic is blocked and in this case they are:

details_msg_s: Failed to parse request body.

details_data_s: %{reqbody_error_msg]

image

Searching for the 200002 number in the Managed rules will display the following rule with the description Failed to parse request body:

image

Unsure of what to make of the details, a case was opened with Microsoft but the engineer was unable to find any additional information for this error but was able to suggest that the following is what was happening:

When a request to sign into the https://sit.domain.com/ portal, the webpage directing the traffic to sitapp.domain.com is sending some strange or malformed data in the request body which causes the Front Door’s WAF policy to think there may be an attack. Their suggestion was to check the request body for any formatting error that would be triggering front door.

Workaround

I’ve requested the developer to look into this and for the time being changed the action for rule 200002 to log rather than block on anomaly so the portal login would start working:

imageimage

Not the best solution but serves as a workaround. Hope this helps anyone looking for information on how to troubleshoot Azure Front Door WAF policy prevention blocks.

Thursday, October 6, 2022

Azure Function App fails with: “ERROR: Assembly with same name is already loaded”

I was recently notified by a colleague that the Azure Function I had demonstrated in my previous post:

Create an automated report for Office 365 / Microsoft 365 license usage with friendly names using Azure a Function App and Logic Apps
http://terenceluk.blogspot.com/2022/07/create-automated-report-for-office-365.html

… would fail and no longer report the licenses and the error messages are as follow:

2022-10-05T10:22:18 Welcome, you are now connected to log-streaming service. The default timeout is 2 hours. Change the timeout with the App Setting SCM_LOGSTREAM_TIMEOUT (in seconds).

2022-10-05T10:22:29.646 [Error] ERROR: Assembly with same name is already loadedException :Type : System.IO.FileLoadExceptionMessage : Assembly with same name is already loadedTargetSite :Name : LoadBinaryModuleDeclaringType : Microsoft.PowerShell.Commands.ModuleCmdletBaseMemberType : MethodModule : System.Management.Automation.dllStackTrace :at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo parentModule, Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found, String shortModuleName, Boolean disableFormatUpdates)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(String fileName, String moduleBase, String prefix, SessionState ss, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found)at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name)at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName_WithTelemetry(ImportModuleOptions importModuleOptions, String name)at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()at System.Management.Automation.CommandProcessor.ProcessRecord()Source : System.Management.AutomationHResult : -2146232799CategoryInfo : NotSpecified: (:) [Import-Module], FileLoadExceptionFullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleScriptLineNumber : 4OffsetInLine : 9HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1Line : $null = Import-Module -Name $ModulePathPositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1:4 char:9+ $null = Import-Module -Name $ModulePath+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0PSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1InvocationName : Import-ModuleCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 4at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: Assembly with same name is already loadedException :Type : System.IO.FileLoadExceptionMessage : Assembly with same name is already loadedTargetSite :Name : LoadBinaryModuleDeclaringType : Microsoft.PowerShell.Commands.ModuleCmdletBaseMemberType : MethodModule : System.Management.Automation.dllStackTrace :at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo parentModule, Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found, String shortModuleName, Boolean disableFormatUpdates)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(String fileName, String moduleBase, String prefix, SessionState ss, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found)at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name)at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName_WithTelemetry(ImportModuleOptions importModuleOptions, String name)at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()at System.Management.Automation.CommandProcessor.ProcessRecord()Source : System.Management.AutomationHResult : -2146232799CategoryInfo : NotSpecified: (:) [Import-Module], FileLoadExceptionFullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleScriptLineNumber : 4OffsetInLine : 9HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1Line : $null = Import-Module -Name $ModulePathPositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1:4 char:9+ $null = Import-Module -Name $ModulePath+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0PSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1InvocationName : Import-ModuleCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 4at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20Exception: Assembly with same name is already loadedStack: at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo parentModule, Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found, String shortModuleName, Boolean disableFormatUpdates)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(Boolean trySnapInName, String moduleName, String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean loadTypes, Boolean loadFormats, Boolean& found)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(String fileName, String moduleBase, String prefix, SessionState ss, ImportModuleOptions& options, ManifestProcessingFlags manifestProcessingFlags, Boolean& found)at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions importModuleOptions, String name)at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName_WithTelemetry(ImportModuleOptions importModuleOptions, String name)at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()at System.Management.Automation.CommandProcessor.ProcessRecord()

2022-10-05T10:22:31.425 [Warning] The Function app may be missing a module containing the 'Get-ScriptCmdlet' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause.

2022-10-05T10:22:31.638 [Error] ERROR: The term 'Get-ScriptCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Exception :Type : System.Management.Automation.CommandNotFoundExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : The term 'Get-ScriptCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.HResult : -2146233087TargetObject : Get-ScriptCmdletCategoryInfo : ObjectNotFound: (Get-ScriptCmdlet:String) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : CommandNotFoundExceptionInvocationInfo :ScriptLineNumber : 11OffsetInLine : 36HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1Line : Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $CustomScriptPath) -Alias (Get-ScriptCmdlet -ScriptFolder $CustomScriptPath -AsAlias)PositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1:11 char:36+ Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $Cu …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScriptsPSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1InvocationName : Get-ScriptCmdletCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1: line 11at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 12at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 11at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20CommandName : Get-ScriptCmdletTargetSite :Name : LookupCommandInfoDeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.0.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Message : The term 'Get-ScriptCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Data : System.Collections.ListDictionaryInternalSource : System.Management.AutomationHResult : -2146233087TargetObject : Get-ScriptCmdletCategoryInfo : ObjectNotFound: (Get-ScriptCmdlet:String) [], CommandNotFoundExceptionFullyQualifiedErrorId : CommandNotFoundExceptionInvocationInfo :ScriptLineNumber : 11OffsetInLine : 36HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1Line : Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $CustomScriptPath) -Alias (Get-ScriptCmdlet -ScriptFolder $CustomScriptPath -AsAlias)PositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1:11 char:36+ Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $Cu …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScriptsPSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1InvocationName : Get-ScriptCmdletCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1: line 11at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 12at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 11at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: The term 'Get-ScriptCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Exception :Type : System.Management.Automation.CommandNotFoundExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : The term 'Get-ScriptCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.HResult : -2146233087TargetObject : Get-ScriptCmdletCategoryInfo : ObjectNotFound: (Get-ScriptCmdlet:String) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : CommandNotFoundExceptionInvocationInfo :ScriptLineNumber : 11OffsetInLine : 36HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1Line : Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $CustomScriptPath) -Alias (Get-ScriptCmdlet -ScriptFolder $CustomScriptPath -AsAlias)PositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1:11 char:36+ Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $Cu …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScriptsPSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1InvocationName : Get-ScriptCmdletCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1: line 11at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 12at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 11at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20CommandName : Get-ScriptCmdletTargetSite :Name : LookupCommandInfoDeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.0.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Message : The term 'Get-ScriptCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Data : System.Collections.ListDictionaryInternalSource : System.Management.AutomationHResult : -2146233087TargetObject : Get-ScriptCmdletCategoryInfo : ObjectNotFound: (Get-ScriptCmdlet:String) [], CommandNotFoundExceptionFullyQualifiedErrorId : CommandNotFoundExceptionInvocationInfo :ScriptLineNumber : 11OffsetInLine : 36HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1Line : Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $CustomScriptPath) -Alias (Get-ScriptCmdlet -ScriptFolder $CustomScriptPath -AsAlias)PositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1:11 char:36+ Export-ModuleMember -Function (Get-ScriptCmdlet -ScriptFolder $Cu …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScriptsPSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1InvocationName : Get-ScriptCmdletCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\StartupScripts\ExportCustomCommands.ps1: line 11at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 12at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 11at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20Exception: The term 'Get-ScriptCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Stack: at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

2022-10-05T10:22:31.734 [Warning] The Function app may be missing a module containing the 'Get-ModuleCmdlet' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause.

2022-10-05T10:22:32.075 [Error] ERROR: The term 'Get-ModuleCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Exception :Type : System.Management.Automation.CommandNotFoundExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : The term 'Get-ModuleCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.HResult : -2146233087TargetObject : Get-ModuleCmdletCategoryInfo : ObjectNotFound: (Get-ModuleCmdlet:String) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : CommandNotFoundExceptionInvocationInfo :ScriptLineNumber : 17OffsetInLine : 30HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1Line : Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath) -Alias (Get-ModuleCmdlet -ModulePath $ModulePath -AsAlias)PositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1:17 char:30+ Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0PSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1InvocationName : Get-ModuleCmdletCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 17at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20CommandName : Get-ModuleCmdletTargetSite :Name : LookupCommandInfoDeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.0.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Message : The term 'Get-ModuleCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Data : System.Collections.ListDictionaryInternalSource : System.Management.AutomationHResult : -2146233087TargetObject : Get-ModuleCmdletCategoryInfo : ObjectNotFound: (Get-ModuleCmdlet:String) [], CommandNotFoundExceptionFullyQualifiedErrorId : CommandNotFoundExceptionInvocationInfo :ScriptLineNumber : 17OffsetInLine : 30HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1Line : Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath) -Alias (Get-ModuleCmdlet -ModulePath $ModulePath -AsAlias)PositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1:17 char:30+ Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0PSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1InvocationName : Get-ModuleCmdletCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 17at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: The term 'Get-ModuleCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Exception :Type : System.Management.Automation.CommandNotFoundExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : The term 'Get-ModuleCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.HResult : -2146233087TargetObject : Get-ModuleCmdletCategoryInfo : ObjectNotFound: (Get-ModuleCmdlet:String) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : CommandNotFoundExceptionInvocationInfo :ScriptLineNumber : 17OffsetInLine : 30HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1Line : Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath) -Alias (Get-ModuleCmdlet -ModulePath $ModulePath -AsAlias)PositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1:17 char:30+ Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0PSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1InvocationName : Get-ModuleCmdletCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 17at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20CommandName : Get-ModuleCmdletTargetSite :Name : LookupCommandInfoDeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.0.9.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Message : The term 'Get-ModuleCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Data : System.Collections.ListDictionaryInternalSource : System.Management.AutomationHResult : -2146233087TargetObject : Get-ModuleCmdletCategoryInfo : ObjectNotFound: (Get-ModuleCmdlet:String) [], CommandNotFoundExceptionFullyQualifiedErrorId : CommandNotFoundExceptionInvocationInfo :ScriptLineNumber : 17OffsetInLine : 30HistoryId : 1ScriptName : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1Line : Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath) -Alias (Get-ModuleCmdlet -ModulePath $ModulePath -AsAlias)PositionMessage : At C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1:17 char:30+ Export-ModuleMember -Cmdlet (Get-ModuleCmdlet -ModulePath $ModulePath …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0PSCommandPath : C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1InvocationName : Get-ModuleCmdletCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Authentication\1.10.0\Microsoft.Graph.Authentication.psm1: line 17at <ScriptBlock>, C:\home\site\wwwroot\profile.ps1: line 20Exception: The term 'Get-ModuleCmdlet' is not recognized as the name of a cmdlet, function, script file, or operable program.Check the spelling of the name, or if a path was included, verify that the path is correct and try again.Stack: at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

2022-10-05T10:22:32.509 [Error] Errors reported while executing profile.ps1. See logs for detailed errors. Profile location: C:\home\site\wwwroot\profile.ps1.

2022-10-05T10:22:32.611 [Information] INFORMATION: PowerShell HTTP trigger function processed a request.

2022-10-05T10:22:34.589 [Error] ERROR: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.Exception :Type : System.IO.FileNotFoundExceptionMessage : Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.FileName : Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeedTargetSite :Name : MoveNextDeclaringType : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph+<ProcessRecordAsync>d__56, Microsoft.Graph.Authentication, Version=1.12.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : Microsoft.Graph.Authentication.dllStackTrace :at Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph.ProcessRecordAsync()Source : Microsoft.Graph.AuthenticationHResult : -2147024894CategoryInfo : NotSpecified: (:) [Connect-MgGraph], FileNotFoundExceptionFullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraphInvocationInfo :MyCommand : Connect-MgGraphScriptLineNumber : 85OffsetInLine : 1HistoryId : 1ScriptName : C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1Line : Connect-MgGraph -ClientID $appId -TenantId $tenantID -CertificateThumbprint $thumb ## Or -CertificateName "M365-License"PositionMessage : At C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1:85 char:1+ Connect-MgGraph -ClientID $appId -TenantId $tenantID -CertificateThum …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\site\wwwroot\HttpTrigger-Get-LicensesPSCommandPath : C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1InvocationName : Connect-MgGraphCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1: line 85PipelineIterationInfo :Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.Exception :Type : System.IO.FileNotFoundExceptionMessage : Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.FileName : Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeedTargetSite :Name : MoveNextDeclaringType : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph+<ProcessRecordAsync>d__56, Microsoft.Graph.Authentication, Version=1.12.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : Microsoft.Graph.Authentication.dllStackTrace :at Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph.ProcessRecordAsync()Source : Microsoft.Graph.AuthenticationHResult : -2147024894CategoryInfo : NotSpecified: (:) [Connect-MgGraph], FileNotFoundExceptionFullyQualifiedErrorId : Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraphInvocationInfo :MyCommand : Connect-MgGraphScriptLineNumber : 85OffsetInLine : 1HistoryId : 1ScriptName : C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1Line : Connect-MgGraph -ClientID $appId -TenantId $tenantID -CertificateThumbprint $thumb ## Or -CertificateName "M365-License"PositionMessage : At C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1:85 char:1+ Connect-MgGraph -ClientID $appId -TenantId $tenantID -CertificateThum …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\site\wwwroot\HttpTrigger-Get-LicensesPSCommandPath : C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1InvocationName : Connect-MgGraphCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1: line 85PipelineIterationInfo :Exception: Could not load file or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.Stack: at Microsoft.Graph.PowerShell.Authentication.Cmdlets.ConnectMgGraph.ProcessRecordAsync()

2022-10-05T10:22:35.196 [Error] ERROR: Authentication needed, call Connect-MgGraph.Exception :Type : System.Security.Authentication.AuthenticationExceptionTargetSite :Name : GetGraphHttpClientDeclaringType : Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpersMemberType : MethodModule : Microsoft.Graph.Authentication.dllStackTrace :at Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient(InvocationInfo invocationInfo, IAuthContext authContext)at Microsoft.Graph.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline)at Microsoft.Graph.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName)at Microsoft.Graph.PowerShell.Cmdlets.GetMgSubscribedSku_List1.ProcessRecordAsync()Message : Authentication needed, call Connect-MgGraph.Source : Microsoft.Graph.AuthenticationHResult : -2146233087CategoryInfo : NotSpecified: (:) [Get-MgSubscribedSku_List1], AuthenticationExceptionFullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgSubscribedSku_List1InvocationInfo :MyCommand : Get-MgSubscribedSku_List1ScriptLineNumber : 34OffsetInLine : 1HistoryId : 1ScriptName : C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1Line : $licenseUsage = Get-MgSubscribedSku | Select-Object -Property SkuPartNumber,CapabilityStatus,@{Name="PrepaidUnits";expression={$_.PrepaidUnits.Enabled -join ";"}},ConsumedUnits,SkuId,AppliesToPositionMessage : At C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1:34 char:1+ $licenseUsage = Get-MgSubscribedSku | Select-Object -Property SkuPart …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\site\wwwroot\HttpTrigger-Get-LicensesPSCommandPath : C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1InvocationName : Get-MgSubscribedSkuCommandOrigin : InternalScriptStackTrace : at Get-MgSubscribedSku<Process>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Identity.DirectoryManagement\1.10.0\exports\v1.0\ProxyCmdletDefinitions.ps1: line 12245at Get-LicenseUsage, C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1: line 34at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1: line 88PipelineIterationInfo :Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: Authentication needed, call Connect-MgGraph.Exception :Type : System.Security.Authentication.AuthenticationExceptionTargetSite :Name : GetGraphHttpClientDeclaringType : Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpersMemberType : MethodModule : Microsoft.Graph.Authentication.dllStackTrace :at Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient(InvocationInfo invocationInfo, IAuthContext authContext)at Microsoft.Graph.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline)at Microsoft.Graph.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName)at Microsoft.Graph.PowerShell.Cmdlets.GetMgSubscribedSku_List1.ProcessRecordAsync()Message : Authentication needed, call Connect-MgGraph.Source : Microsoft.Graph.AuthenticationHResult : -2146233087CategoryInfo : NotSpecified: (:) [Get-MgSubscribedSku_List1], AuthenticationExceptionFullyQualifiedErrorId : Microsoft.Graph.PowerShell.Cmdlets.GetMgSubscribedSku_List1InvocationInfo :MyCommand : Get-MgSubscribedSku_List1ScriptLineNumber : 34OffsetInLine : 1HistoryId : 1ScriptName : C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1Line : $licenseUsage = Get-MgSubscribedSku | Select-Object -Property SkuPartNumber,CapabilityStatus,@{Name="PrepaidUnits";expression={$_.PrepaidUnits.Enabled -join ";"}},ConsumedUnits,SkuId,AppliesToPositionMessage : At C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1:34 char:1+ $licenseUsage = Get-MgSubscribedSku | Select-Object -Property SkuPart …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\site\wwwroot\HttpTrigger-Get-LicensesPSCommandPath : C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1InvocationName : Get-MgSubscribedSkuCommandOrigin : InternalScriptStackTrace : at Get-MgSubscribedSku<Process>, C:\home\data\ManagedDependencies\2210051007461207219.r\Microsoft.Graph.Identity.DirectoryManagement\1.10.0\exports\v1.0\ProxyCmdletDefinitions.ps1: line 12245at Get-LicenseUsage, C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1: line 34at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger-Get-Licenses\run.ps1: line 88PipelineIterationInfo :Exception: Authentication needed, call Connect-MgGraph.Stack: at Microsoft.Graph.PowerShell.Authentication.Helpers.HttpHelpers.GetGraphHttpClient(InvocationInfo invocationInfo, IAuthContext authContext)at Microsoft.Graph.PowerShell.Module.BeforeCreatePipeline(InvocationInfo invocationInfo, HttpPipeline& pipeline)at Microsoft.Graph.PowerShell.Module.CreatePipeline(InvocationInfo invocationInfo, String parameterSetName)at Microsoft.Graph.PowerShell.Cmdlets.GetMgSubscribedSku_List1.ProcessRecordAsync()

2022-10-05T10:22:36.420 [Information] Executed 'Functions.HttpTrigger-Get-Licenses' (Succeeded, Id=67e43323-4ca9-418d-af47-56714cacc89a, Duration=23871ms)

image

image

image

image

image

image

image

image

image

image

image

image

image

I intentionally highlighted the error message:

ERROR: Assembly with same name is already loaded

… because a bit of troubleshooting lead me to confirm that this is an issue caused by the Azure Function App downloading a newer version of the modules defined in the requirements.psd1 file:

clip_image002

To correct the issue, we can Kudu to remove the module.

Every app that is created has a companion app created for it (https://docs.microsoft.com/en-us/azure/app-service/resources-kudu#access-kudu-for-your-app) and this app named Kudu can be accessed via:

Go to: .scm.azurewebsites.net">https://<app-name>.scm.azurewebsites.net

clip_image002[4]

You can browse the directories of the app but clicking on Debug console > PowerShell:

clip_image002[6]

Navigate to: data

clip_image002[8]

Then: ManagedDependencies

clip_image002[10]

You may find several folders in this directory:

clip_image002[12]

Proceed to browse into these folders and you’ll likely two versions downloaded:

clip_image002[14]

Proceed to remove the module that is not needed, which will correct the issue.