Skip to content

HttpClient.Timeout error when using a filter on Get-MGAuditLogSignInΒ #2941

@CloudVikingr

Description

@CloudVikingr

Describe the bug

I am trying to run Get-MGAuditLogSignIn with a filter to retrieve the signin attempts from a specific application (Azure Portal).
When I run the command I get this result:

> $AppId = 'c44b4083-3bb0-49c1-b47d-974e53cbdf3c'
> get-mgauditlogsignin -all -filter "(AppId eq '$AppId')"
Get-MgAuditLogSignIn_List: The request was canceled due to the configured HttpClient.Timeout of 300 seconds elapsing.

If I don't supply the filter the command runs successfully. It returns the results in a paginated manner and does not encounter the HttpClient.Timeout of 300 seconds:

PS C:\temp> Measure-Command { $events = Get-MgAuditLogSIgnin -all }


**TotalSeconds      : 817.4071132**

I can't find any option to override the default timeout using the specified command.

Expected behavior

I would expect that supplying a filter to the request would result in the specified results returning. If there are a lot of logs, this can take longer than the default timeout of 300s.

How to reproduce

  1. Execute
$AppId = 'c44b4083-3bb0-49c1-b47d-974e53cbdf3c'
get-mgauditlogsignin -all -filter "(AppId eq '$AppId')"

SDK Version

2.22.0

Latest version known to work for scenario above?

No response

Known Workarounds

Retrieve the entire dataset and filter on the client side.

$AppId = 'c44b4083-3bb0-49c1-b47d-974e53cbdf3c'
$events = Get-MgAuditLogSIgnin -all
$events | where {$_.AppId -eq $AppId}

Debug output

Click to expand log ``` PS C:\temp> get-mgauditlogsignin -all -filter "(AppId eq '$AppId')" -debug DEBUG: [CmdletBeginProcessing]: - Get-MgAuditLogSignIn begin processing with parameterSet 'List'. DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'. DEBUG: [Authentication]: - Scopes: [AuditLog.Read.All, Device.Read.All, DeviceManagementConfiguration.Read.All, DeviceManagementManagedDevices.Read.All, Directory.Read.All, Directory.ReadWrite.All, Files.Read.All, Group.Read.All, Group.ReadWrite.All, OnPremDirectorySynchronization.ReadWrite.All, openid, Organization.Read.All, Policy.Read.All, Policy.Read.ConditionalAccess, Policy.ReadWrite.ConditionalAccess, profile, RoleManagement.ReadWrite.Directory, SecurityIncident.Read.All, Sites.Read.All, ThreatIntelligence.Read.All, User.Read, User.Read.All, UserAuthenticationMethod.Read.All, email]. DEBUG: [CmdletException]: Received exception with message 'TaskCanceledException - The request was canceled due to the configured HttpClient.Timeout of 300 seconds elapsing. : at System.Net.Http.HttpClient.HandleFailure(Exception e, Boolean telemetryStarted, HttpResponseMessage response, CancellationTokenSource cts, CancellationToken cancellationToken, CancellationTokenSource pendingRequestsCts) at System.Net.Http.HttpClient.g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken) at Microsoft.Graph.PowerShell.Reports.AuditLogListSignIn_Call(HttpRequestMessage request, Func`3 on2Xx, Func`3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.Reports.AuditLogListSignIn_Call(HttpRequestMessage request, Func`3 on2Xx, Func`3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.Reports.AuditLogListSignIn(Nullable`1 Top, Nullable`1 Skip, String Search, String Filter, Nullable`1 Count, String[] Orderby, String[] Select, String[] Expand, IDictionary headers, Func`3 on2Xx, Func`3 onDefault, IEventListener eventListener, ISendAsync sender) at Microsoft.Graph.PowerShell.Cmdlets.GetMgAuditLogSignIn_List.ProcessRecordAsync()' Get-MgAuditLogSignIn_List: The request was canceled due to the configured HttpClient.Timeout of 300 seconds elapsing. DEBUG: [CmdletEndProcessing]: - Get-MgAuditLogSignIn end processing.
</details>


### Configuration

- OS: Windows 11

Name Value


PSVersion 7.4.4
PSEdition Core
GitCommitId 7.4.4
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0


### Other information

_No response_

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions