Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.27k stars 3.87k forks source link

Invoke-AzOperationalInsightsQuery task cancelled before -Wait time elapsed #11663

Open jonarmstrong opened 4 years ago

jonarmstrong commented 4 years ago

Description

Using Invoke-AzOperationalInsightsQuery will throw an A task was cancelled exception before the timeout specified by -Wait has elapsed, ~ 120 seconds until the thread task is cancelled.

Steps to reproduce

Use Invoke-AzOperationalInsightsQuery with a query that takes a long time to complete. The thread task will be cancelled before the timeout specified by -Wait. I can't share the exact query provided, as it is confidential work product, but it involved a regex search on the AzureDiagnostics table, similar to below. Shortening the date time search is effective up to a point, except that when a lot of data is present in the time range, it starts timing-out at the thread task. If I run the same kql query in Azure Monitor, it is able to return results before the max 10m timelimit on the log analytics API.

$query = let regexExpression = @'regexquery here';
search in (AzureDiagnostics) * 
| where TimeGenerated between (ago(300d) .. ago(270d))
| where * matches regex regexExpression

Invoke-AzOperationalInsightsQuery -WorkspaceId '------------------' -Query $query -Wait 600

Environment data

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.18363
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions


    Directory: C:\Users\------------------------------\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     3.6.1                 Az                                  Core,Desk
Script     3.5.0                 Az                                  Core,Desk
Script     2.5.0                 Az                                  Core,Desk
Script     1.7.3                 Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzCo…
Script     1.7.2                 Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzCo…
Script     1.6.1                 Az.Accounts                         Core,Desk {Disable-AzDataCollection, Disable-AzCo…
Script     1.1.1                 Az.Advisor                          Core,Desk {Get-AzAdvisorRecommendation, Enable-Az…
Script     1.0.0                 Az.Advisor                          Core,Desk {Get-AzAdvisorRecommendation, Enable-Az…
Script     1.0.3                 Az.Aks                              Core,Desk {Get-AzAks, New-AzAks, Remove-AzAks, Im…
Script     1.0.1                 Az.Aks                              Core,Desk {Get-AzAks, New-AzAks, Remove-AzAks, Im…
Script     1.1.2                 Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspe…
Script     1.1.0                 Az.AnalysisServices                 Core,Desk {Resume-AzAnalysisServicesServer, Suspe…
Script     1.4.0                 Az.ApiManagement                    Core,Desk {Add-AzApiManagementApiToProduct, Add-A…
Script     1.3.4                 Az.ApiManagement                    Core,Desk {Add-AzApiManagementApiToProduct, Add-A…
Script     1.2.0                 Az.ApiManagement                    Core,Desk {Add-AzApiManagementApiToProduct, Add-A…
Script     1.0.3                 Az.ApplicationInsights              Core,Desk {Get-AzApplicationInsights, New-AzAppli…
Script     1.0.1                 Az.ApplicationInsights              Core,Desk {Get-AzApplicationInsights, New-AzAppli…
Script     1.3.6                 Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Rem…
Script     1.3.1                 Az.Automation                       Core,Desk {Get-AzAutomationHybridWorkerGroup, Rem…
Script     2.0.2                 Az.Batch                            Core,Desk {Remove-AzBatchAccount, Get-AzBatchAcco…
Script     1.1.0                 Az.Batch                            Core,Desk {Remove-AzBatchAccount, Get-AzBatchAcco…
Script     1.0.2                 Az.Billing                          Core,Desk {Get-AzBillingInvoice, Get-AzBillingPer…
Script     1.0.0                 Az.Billing                          Core,Desk {Get-AzBillingInvoice, Get-AzBillingPer…
Script     1.4.2                 Az.Cdn                              Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoU…
Script     1.3.0                 Az.Cdn                              Core,Desk {Get-AzCdnProfile, Get-AzCdnProfileSsoU…
Script     1.2.3                 Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-Az…
Script     1.2.0                 Az.CognitiveServices                Core,Desk {Get-AzCognitiveServicesAccount, Get-Az…
Script     3.5.0                 Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvaila…
Script     2.4.1                 Az.Compute                          Core,Desk {Remove-AzAvailabilitySet, Get-AzAvaila…
Script     1.0.3                 Az.ContainerInstance                Core,Desk {New-AzContainerGroup, Get-AzContainerG…
Script     1.0.1                 Az.ContainerInstance                Core,Desk {New-AzContainerGroup, Get-AzContainerG…
Script     1.1.1                 Az.ContainerRegistry                Core,Desk {New-AzContainerRegistry, Get-AzContain…
Script     1.1.0                 Az.ContainerRegistry                Core,Desk {New-AzContainerRegistry, Get-AzContain…
Script     1.1.0                 Az.DataBoxEdge                      Core,Desk {Get-AzDataBoxEdgeJob, Get-AzDataBoxEdg…
Script     1.6.1                 Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFact…
Script     1.1.3                 Az.DataFactory                      Core,Desk {Set-AzDataFactoryV2, Update-AzDataFact…
Script     1.0.2                 Az.DataLakeAnalytics                Core,Desk {Get-AzDataLakeAnalyticsDataSource, New…
Script     1.0.0                 Az.DataLakeAnalytics                Core,Desk {Get-AzDataLakeAnalyticsDataSource, New…
Script     1.2.7                 Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, …
Script     1.2.6                 Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, …
Script     1.2.1                 Az.DataLakeStore                    Core,Desk {Get-AzDataLakeStoreTrustedIdProvider, …
Script     1.1.0                 Az.DeploymentManager                Core,Desk {Get-AzDeploymentManagerArtifactSource,…
Script     1.0.0                 Az.DeploymentManager                Core,Desk {Get-AzDeploymentManagerArtifactSource,…
Script     1.0.2                 Az.DevTestLabs                      Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzD…
Script     1.0.0                 Az.DevTestLabs                      Core,Desk {Get-AzDtlAllowedVMSizesPolicy, Get-AzD…
Script     1.1.2                 Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordCon…
Script     1.1.1                 Az.Dns                              Core,Desk {Get-AzDnsRecordSet, New-AzDnsRecordCon…
Script     1.2.3                 Az.EventGrid                        Core,Desk {New-AzEventGridTopic, Get-AzEventGridT…
Script     1.2.1                 Az.EventGrid                        Core,Desk {New-AzEventGridTopic, Get-AzEventGridT…
Script     1.4.3                 Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHu…
Script     1.3.0                 Az.EventHub                         Core,Desk {New-AzEventHubNamespace, Get-AzEventHu…
Script     1.4.0                 Az.FrontDoor                        Core,Desk {New-AzFrontDoor, Get-AzFrontDoor, Set-…
Script     1.1.0                 Az.FrontDoor                        Core,Desk {New-AzFrontDoor, Get-AzFrontDoor, Set-…
Script     3.0.3                 Az.HDInsight                        Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqo…
Script     2.0.0                 Az.HDInsight                        Core,Desk {Get-AzHDInsightJob, New-AzHDInsightSqo…
Script     1.0.1                 Az.HealthcareApis                   Core,Desk {New-AzHealthcareApisService, Remove-Az…
Script     2.2.0                 Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubC…
Script     2.1.0                 Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubC…
Script     1.2.0                 Az.IotHub                           Core,Desk {Add-AzIotHubKey, Get-AzIotHubEventHubC…
Script     1.5.1                 Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKe…
Script     1.3.0                 Az.KeyVault                         Core,Desk {Add-AzKeyVaultCertificate, Update-AzKe…
Script     1.3.2                 Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get…
Script     1.3.0                 Az.LogicApp                         Core,Desk {Get-AzIntegrationAccountAgreement, Get…
Script     1.1.3                 Az.MachineLearning                  Core,Desk {Move-AzMlCommitmentAssociation, Get-Az…
Script     1.1.0                 Az.MachineLearning                  Core,Desk {Move-AzMlCommitmentAssociation, Get-Az…
Script     1.0.2                 Az.ManagedServices                  Core,Desk {Get-AzManagedServicesAssignment, New-A…
Script     1.0.0                 Az.ManagedServices                  Core,Desk {Get-AzManagedServicesAssignment, New-A…
Script     1.0.2                 Az.MarketplaceOrdering              Core,Desk {Get-AzMarketplaceTerms, Set-AzMarketpl…
Script     1.0.0                 Az.MarketplaceOrdering              Core,Desk {Get-AzMarketplaceTerms, Set-AzMarketpl…
Script     1.1.1                 Az.Media                            Core,Desk {Sync-AzMediaServiceStorageKey, Set-AzM…
Script     1.1.0                 Az.Media                            Core,Desk {Sync-AzMediaServiceStorageKey, Set-AzM…
Script     1.6.1                 Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, …
Script     1.6.0                 Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, …
Script     1.2.1                 Az.Monitor                          Core,Desk {Get-AzMetricDefinition, Get-AzMetric, …
Script     2.3.2                 Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthentication…
Script     2.3.1                 Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthentication…
Script     1.12.0                Az.Network                          Core,Desk {Add-AzApplicationGatewayAuthentication…
Script     1.1.1                 Az.NotificationHubs                 Core,Desk {Get-AzNotificationHub, Get-AzNotificat…
Script     1.1.0                 Az.NotificationHubs                 Core,Desk {Get-AzNotificationHub, Get-AzNotificat…
Script     1.3.4                 Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivity…
Script     1.3.2                 Az.OperationalInsights              Core,Desk {New-AzOperationalInsightsAzureActivity…
Script     1.2.0                 Az.PolicyInsights                   Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, …
Script     1.1.2                 Az.PolicyInsights                   Core,Desk {Get-AzPolicyEvent, Get-AzPolicyState, …
Script     1.1.1                 Az.PowerBIEmbedded                  Core,Desk {Remove-AzPowerBIWorkspaceCollection, G…
Script     1.1.0                 Az.PowerBIEmbedded                  Core,Desk {Remove-AzPowerBIWorkspaceCollection, G…
Script     1.0.2                 Az.PrivateDns                       Core,Desk {Get-AzPrivateDnsZone, Remove-AzPrivate…
Script     2.7.0                 Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, …
Script     1.4.3                 Az.RecoveryServices                 Core,Desk {Get-AzRecoveryServicesBackupProperty, …
Script     1.2.1                 Az.RedisCache                       Core,Desk {Remove-AzRedisCachePatchSchedule, New-…
Script     1.1.0                 Az.RedisCache                       Core,Desk {Remove-AzRedisCachePatchSchedule, New-…
Script     1.0.3                 Az.Relay                            Core,Desk {New-AzRelayNamespace, Get-AzRelayNames…
Script     1.0.1                 Az.Relay                            Core,Desk {New-AzRelayNamespace, Get-AzRelayNames…
Script     1.12.0                Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRole…
Script     1.11.0                Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRole…
Script     1.6.1                 Az.Resources                        Core,Desk {Get-AzProviderOperation, Remove-AzRole…
Script     0.7.7                 Az.Security                         Core,Desk {Get-AzSecurityAlert, Set-AzSecurityAle…
Script     1.4.1                 Az.ServiceBus                       Core,Desk {New-AzServiceBusNamespace, Get-AzServi…
Script     1.3.0                 Az.ServiceBus                       Core,Desk {New-AzServiceBusNamespace, Get-AzServi…
Script     2.0.1                 Az.ServiceFabric                    Core,Desk {Add-AzServiceFabricClientCertificate, …
Script     1.1.1                 Az.ServiceFabric                    Core,Desk {Add-AzServiceFabricApplicationCertific…
Script     1.1.1                 Az.SignalR                          Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSi…
Script     1.0.2                 Az.SignalR                          Core,Desk {New-AzSignalR, Get-AzSignalR, Get-AzSi…
Script     2.4.0                 Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryp…
Script     2.3.0                 Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryp…
Script     1.13.1                Az.Sql                              Core,Desk {Get-AzSqlDatabaseTransparentDataEncryp…
Script     1.1.0                 Az.SqlVirtualMachine                Core,Desk {New-AzSqlVM, Get-AzSqlVM, Update-AzSql…
Script     1.13.0                Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAcc…
Script     1.12.0                Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAcc…
Script     1.5.1                 Az.Storage                          Core,Desk {Get-AzStorageAccount, Get-AzStorageAcc…
Script     1.2.3                 Az.StorageSync                      Core,Desk {Invoke-AzStorageSyncCompatibilityCheck…
Script     1.2.0                 Az.StorageSync                      Core,Desk {Invoke-AzStorageSyncCompatibilityCheck…
Script     1.0.1                 Az.StreamAnalytics                  Core,Desk {Get-AzStreamAnalyticsFunction, Get-AzS…
Script     1.0.0                 Az.StreamAnalytics                  Core,Desk {Get-AzStreamAnalyticsFunction, Get-AzS…
Script     1.0.3                 Az.TrafficManager                   Core,Desk {Add-AzTrafficManagerCustomHeaderToEndp…
Script     1.0.1                 Az.TrafficManager                   Core,Desk {Add-AzTrafficManagerCustomHeaderToEndp…
Script     1.7.0                 Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppService…
Script     1.6.0                 Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppService…
Script     1.4.0                 Az.Websites                         Core,Desk {Get-AzAppServicePlan, Set-AzAppService…
Binary     2.0.2.76              AzureAD                             Desk
Binary     2.0.2.4               AzureAD                             Desk
Script     2.0.0                 BuildHelpers                        Desk      {Add-TestResultToAppveyor, Export-Metad…
Binary     2.0.0.1762            Microsoft.Azure.ActiveDirectory.PI… Desk      {Connect-PimService, Disable-Privileged…
Binary     6.1902.1.…            Microsoft.Graph.Intune              Desk      {Set-MSGraphAlias, Get-MSGraphAllPages,…
Script     1.2                   MSCommerce                          Desk      {Connect-MSCommerce, Get-MSCommercePoli…
Script     2.0.385               oh-my-posh                          Desk      {Show-Colors, Show-ThemeColors, Show-Th…
Script     1.4.4                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     4.4.2                 Pester                              Desk      {Describe, Context, It, Should…}
Script     0.12.0                platyPS                             Desk      {New-MarkdownHelp, Get-MarkdownMetadata…
Script     1.0.0      beta3      posh-git                            Desk      {Add-PoshGitToProfile, Expand-GitComman…
Script     4.7.4                 psake                               Desk      {Invoke-psake, Invoke-Task, Get-PSakeSc…
Script     0.3.0                 PSDepend                            Desk      {Get-Dependency, Get-PSDependScript, Ge…
Script     1.18.3                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptA…
Script     1.18.1                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptA…
Script     1.18.0                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptA…
Script     1.17.1                PSScriptAnalyzer                    Desk      {Get-ScriptAnalyzerRule, Invoke-ScriptA…
Script     21.1.18080            SqlServer                           Desk      {Add-RoleMember, Add-SqlAvailabilityDat…
Manifest   4.2                   WindowsAutoPilotIntune              Desk      {Add-EnrollmentStatusPage, Invoke-Autop…
Script     1.0.0                 WindowsCompatibility                Core      {Initialize-WinSession, Add-WinFunction…

    Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   7.0.0.0               CimCmdlets                          Core      {Get-CimAssociatedInstance, Get-CimClas…
Manifest   1.2.5                 Microsoft.PowerShell.Archive        Desk      {Compress-Archive, Expand-Archive}
Manifest   7.0.0.0               Microsoft.PowerShell.Diagnostics    Core      {Get-WinEvent, New-WinEvent, Get-Counte…
Manifest   7.0.0.0               Microsoft.PowerShell.Host           Core      {Start-Transcript, Stop-Transcript}
Manifest   7.0.0.0               Microsoft.PowerShell.Management     Core      {Add-Content, Clear-Content, Get-Clipbo…
Manifest   7.0.0.0               Microsoft.PowerShell.Security       Core      {Get-Acl, Set-Acl, Get-PfxCertificate, …
Manifest   7.0.0.0               Microsoft.PowerShell.Utility        Core      {Export-Alias, Get-Alias, Import-Alias,…
Manifest   7.0.0.0               Microsoft.WSMan.Management          Core      {Disable-WSManCredSSP, Enable-WSManCred…
Script     1.4.6                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     2.2.3                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…
Script     2.0.5                 PSDesiredStateConfiguration         Core      {Configuration, New-DscChecksum, Get-Ds…
Script     7.0.0.0               PSDiagnostics                       Core      {Disable-PSTrace, Disable-PSWSManCombin…
Script     2.0.0                 PSReadLine                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLi…
Binary     2.0.3                 ThreadJob                           Desk      Start-ThreadJob

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.0.1                 Microsoft.PowerShell.Operation.Val… Desk      {Get-OperationValidation, Invoke-Operat…
Script     1.3.1                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-Package…
Script     4.6.0                 Pester                              Desk      {Describe, Context, It, Should…}
Script     3.4.0                 Pester                              Desk      {Describe, Context, It, Should…}
Script     2.0.4                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-M…
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Modu…
Script     2.0.0      beta2      PSReadline                          Desk      {Get-PSReadLineKeyHandler, Set-PSReadLi…

    Directory: C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   1.0.0.0               AppBackgroundTask                   Core,Desk {Disable-AppBackgroundTaskDiagnosticLog…
Manifest   2.0.1.0               Appx                                Core,Desk {Add-AppxPackage, Get-AppxPackage, Get-…
Script     1.0.0.0               AssignedAccess                      Core,Desk {Clear-AssignedAccess, Get-AssignedAcce…
Manifest   1.0.0.0               BitLocker                           Core,Desk {Unlock-BitLocker, Suspend-BitLocker, R…
Manifest   1.0.0.0               BranchCache                         Core,Desk {Add-BCDataCacheExtension, Clear-BCCach…
Manifest   1.0                   ConfigDefender                      Core,Desk {Get-MpPreference, Set-MpPreference, Ad…
Manifest   1.0                   Defender                            Core,Desk {Get-MpPreference, Set-MpPreference, Ad…
Manifest   1.0.2.0               DeliveryOptimization                Core,Desk {Delete-DeliveryOptimizationCache, Get-…
Manifest   1.0.0.0               DirectAccessClientComponents        Core,Desk {Disable-DAManualEntryPointSelection, E…
Script     3.0                   Dism                                Core,Desk {Add-AppxProvisionedPackage, Add-Window…
Manifest   1.0.0.0               DnsClient                           Core,Desk {Resolve-DnsName, Clear-DnsClientCache,…
Manifest   1.0.0.0               EventTracingManagement              Core,Desk {Start-EtwTraceSession, New-EtwTraceSes…
Manifest   2.0.0.0               International                       Core,Desk {Get-WinDefaultInputMethodOverride, Set…
Manifest   3.0.0.0               Microsoft.PowerShell.Diagnostics    Core,Desk {Get-WinEvent, Get-Counter, Import-Coun…
Manifest   1.0.0.0               Microsoft.PowerShell.LocalAccounts  Core,Desk {Add-LocalGroupMember, Disable-LocalUse…
Manifest   3.1.0.0               Microsoft.PowerShell.Management     Core,Desk {Add-Content, Clear-Content, Clear-Item…
Manifest   1.0                   MMAgent                             Core,Desk {Disable-MMAgent, Enable-MMAgent, Set-M…
Manifest   2.0.0.0               NetAdapter                          Core,Desk {Disable-NetAdapter, Disable-NetAdapter…
Manifest   1.0.0.0               NetConnection                       Core,Desk {Get-NetConnectionProfile, Set-NetConne…
Manifest   1.0.0.0               NetEventPacketCapture               Core,Desk {New-NetEventSession, Remove-NetEventSe…
Manifest   2.0.0.0               NetLbfo                             Core,Desk {Add-NetLbfoTeamMember, Add-NetLbfoTeam…
Manifest   1.0.0.0               NetNat                              Core,Desk {Get-NetNat, Get-NetNatExternalAddress,…
Manifest   2.0.0.0               NetQos                              Core,Desk {Get-NetQosPolicy, Set-NetQosPolicy, Re…
Manifest   2.0.0.0               NetSecurity                         Core,Desk {Get-DAPolicyChange, New-NetIPsecAuthPr…
Manifest   1.0.0.0               NetSwitchTeam                       Core,Desk {New-NetSwitchTeam, Remove-NetSwitchTea…
Manifest   1.0.0.0               NetTCPIP                            Core,Desk {Get-NetIPAddress, Get-NetIPInterface, …
Manifest   1.0.0.0               NetworkConnectivityStatus           Core,Desk {Get-DAConnectionStatus, Get-NCSIPolicy…
Manifest   1.0.0.0               NetworkSwitchManager                Core,Desk {Disable-NetworkSwitchEthernetPort, Ena…
Manifest   1.0.0.0               NetworkTransition                   Core,Desk {Add-NetIPHttpsCertBinding, Disable-Net…
Manifest   1.0.0.0               PcsvDevice                          Core,Desk {Get-PcsvDevice, Start-PcsvDevice, Stop…
Manifest   1.0.0.0               PnpDevice                           Core,Desk {Get-PnpDevice, Get-PnpDeviceProperty, …
Manifest   1.1                   PrintManagement                     Core,Desk {Add-Printer, Add-PrinterDriver, Add-Pr…
Binary     1.0.11                ProcessMitigations                  Core,Desk {Get-ProcessMitigation, Set-ProcessMiti…
Manifest   1.0.0.0               ScheduledTasks                      Core,Desk {Get-ScheduledTask, Set-ScheduledTask, …
Manifest   2.0.0.0               SecureBoot                          Core,Desk {Confirm-SecureBootUEFI, Set-SecureBoot…
Manifest   2.0.0.0               SmbShare                            Core,Desk {Get-SmbShare, Remove-SmbShare, Set-Smb…
Manifest   2.0.0.0               SmbWitness                          Core,Desk {Get-SmbWitnessClient, Move-SmbWitnessC…
Manifest   1.0.0.0               StartLayout                         Core,Desk {Export-StartLayout, Import-StartLayout…
Manifest   2.0.0.0               Storage                             Core,Desk {Add-InitiatorIdToMaskingSet, Add-Parti…
Manifest   1.0.0.0               TroubleshootingPack                 Core,Desk {Get-TroubleshootingPack, Invoke-Troubl…
Manifest   2.0.0.0               TrustedPlatformModule               Core,Desk {Get-Tpm, Initialize-Tpm, Clear-Tpm, Un…
Binary     2.1.639.0             UEV                                 Core,Desk
Manifest   2.0.0.0               VpnClient                           Core,Desk {Add-VpnConnection, Set-VpnConnection, …
Manifest   1.0.0.0               Wdac                                Core,Desk {Get-OdbcDriver, Set-OdbcDriver, Get-Od…
Manifest   2.0.0.0               Whea                                Core,Desk {Get-WheaMemoryPolicy, Set-WheaMemoryPo…
Manifest   1.0.0.0               WindowsDeveloperLicense             Core,Desk {Get-WindowsDeveloperLicense, Unregiste…
Script     1.0                   WindowsErrorReporting               Core,Desk {Enable-WindowsErrorReporting, Disable-…
Manifest   1.0.0.0               WindowsSearch                       Core,Desk {Get-WindowsSearchSetting, Set-WindowsS…
Manifest   1.0.0.0               WindowsUpdate                       Core,Desk Get-WindowsUpdateLog
Manifest   1.0.0.2               WindowsUpdateProvider               Core,Desk {Get-WUAVersion, Get-WULastInstallation…

    Directory: C:\Program Files (x86)\Microsoft SQL Server\140\Tools\PowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   14.0                  SQLPS                               Desk

    Directory: C:\Program Files\Microsoft Message Analyzer\PowerShell

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.1.0.0               PEF                                 Desk

    Directory: C:\Program Files\Common Files\Skype for Business Online\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Manifest   7.0.0.0               LyncOnlineConnector                 Desk
Script     7.0.0.0               SkypeOnlineConnector                Desk      {Set-WinRMNetworkDelayMS, New-CsOnlineS…

Debug output

DEBUG: 2:22:07 PM - InvokeOperationalInsightsQuery begin processing with ParameterSet 'ByWorkspaceId'.
DEBUG: 2:22:07 PM - using account id '----------------------------'...
DEBUG: [Common.Authentication]: Authenticating using Account: ---------------------------
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '----------------------------', Endpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://api.loganalytics.io', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/-----------------------------/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '----------------------------------', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5843842Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: ADAL PCL.CoreCLR with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is running...

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5844808Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: ADAL PCL.CoreCLR with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is running...

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5845650Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: === Token Acquisition started:
        CacheType: null
        Authentication Target: User
        , Authority Host: login.microsoftonline.com

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5846291Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: === Token Acquisition started:
        Authority: https://login.microsoftonline.com/----------------------------------/
        Resource: https://api.loganalytics.io
        ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
        CacheType: null
        Authentication Target: User

DEBUG: [ADAL]: Verbose: 2020-04-22T19:22:07.5847619Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: Loading from cache.

DEBUG: [ADAL]: Verbose: 2020-04-22T19:22:07.5848099Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: Loading from cache.

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5862088Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: Deserialized 32 items to token cache.

DEBUG: [ADAL]: Verbose: 2020-04-22T19:22:07.5863217Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: Looking up cache for a token...

DEBUG: [ADAL]: Verbose: 2020-04-22T19:22:07.5863599Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: Looking up cache for a token...

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5864333Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: An item matching the requested resource was found in the cache

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5864717Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: An item matching the requested resource was found in the cache

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5865637Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: 27.224840786666668 minutes left until token in cache expires

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5866029Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: 27.224840786666668 minutes left until token in cache expires

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5866393Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5866728Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5868057Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 4/22/2020 7:49:21 PM +00:00

DEBUG: [ADAL]: Information: 2020-04-22T19:22:07.5868433Z: 2af18696-8603-488c-a107-83131bcb234b - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 4/22/2020 7:49:21 PM +00:00Access Token Hash: -----------------------------
         User id: --------------------------------------

DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '04/22/2020 19:49:21 +00:00', MultipleResource? 'True', Tenant: '----------------------------------', UserId: '------------------------'
DEBUG: [Common.Authentication]: User info for token DisplayId: '------------------------', Name: -----------------------, IdProvider: 'https://sts.windows.net/----------------------------------/', Uid: 'fb8936ab-ad98-4c5a-bef0-d2f200951f02'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '04/22/2020 19:49:21 +00:00' Comparing to '04/22/2020 19:22:07 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:27:13.4871436'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
POST

Absolute Uri:
https://api.loganalytics.io/v1/workspaces/----------------------
Headers:

Body:
{
  "query": ""
}

Invoke-AzOperationalInsightsQuery: A task was canceled.
DEBUG: AzureQoSEvent: CommandName - Invoke-AzOperationalInsightsQuery; IsSuccess - False; Duration - 00:02:27.2636269;; Exception - System.Threading.Tasks.TaskCanceledException: A task was canceled.
   at System.Net.Http.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream, TransportContext context, CancellationToken cancellationToken)
   at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream tempBuffer)
   at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Microsoft.Azure.OperationalInsights.OperationalInsightsDataClient.QueryWithHttpMessagesAsync(String query, Nullable`1 timespan, IList`1 workspaces, Dictionary`2 customHeaders, CancellationToken cancellationToken)
   at Microsoft.Azure.OperationalInsights.OperationalInsightsDataClientExtensions.QueryAsync(IOperationalInsightsDataClient operations, String query, Nullable`1 timespan, IList`1 workspaces, CancellationToken cancellationToken)
   at Microsoft.Azure.OperationalInsights.OperationalInsightsDataClientExtensions.Query(IOperationalInsightsDataClient operations, String query, Nullable`1 timespan, IList`1 workspaces)
   at Microsoft.Azure.Commands.OperationalInsights.Query.InvokeOperationalInsightsQuery.ExecuteCmdlet()
   at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
   at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
   at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 2:24:35 PM - InvokeOperationalInsightsQuery end processing.

Error output

Message        : A task was canceled.
StackTrace     :    at System.Net.Http.HttpConnectionResponseContent.SerializeToStreamAsync(Stream stream,
                 TransportContext context, CancellationToken cancellationToken)
                    at System.Net.Http.HttpContent.LoadIntoBufferAsyncCore(Task serializeToStreamTask, MemoryStream
                 tempBuffer)
                    at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request,
                 CancellationTokenSource cts, Boolean disposeCts)
                    at
                 Microsoft.Azure.OperationalInsights.OperationalInsightsDataClient.QueryWithHttpMessagesAsync(String
                 query, Nullable`1 timespan, IList`1 workspaces, Dictionary`2 customHeaders, CancellationToken
                 cancellationToken)
                    at Microsoft.Azure.OperationalInsights.OperationalInsightsDataClientExtensions.QueryAsync(IOperatio
                 nalInsightsDataClient operations, String query, Nullable`1 timespan, IList`1 workspaces,
                 CancellationToken cancellationToken)
                    at Microsoft.Azure.OperationalInsights.OperationalInsightsDataClientExtensions.Query(IOperationalIn
                 sightsDataClient operations, String query, Nullable`1 timespan, IList`1 workspaces)
                    at
                 Microsoft.Azure.Commands.OperationalInsights.Query.InvokeOperationalInsightsQuery.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronously
                 OrAsJob>b__3_0(T c)
                    at
                 Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
                 cmdlet, Action`1 executor)
                    at
                 Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T
                 cmdlet)
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.Threading.Tasks.TaskCanceledException
InvocationInfo : {Invoke-AzOperationalInsightsQuery}
Line           :     $results = Invoke-AzOperationalInsightsQuery -WorkspaceId 'XXXXXXXXXXXXXX'
                 -Query $query -Wait 600 -Debug -IncludeStatistics

Position       : At line:1 char:16
                 + …  $results = Invoke-AzOperationalInsightsQuery -WorkspaceId '---------------- …
                 +               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 10
dingmeng-xue commented 4 years ago

@VeryEarly , please look into it.

jonarmstrong commented 4 years ago

@VeryEarly , @dingmeng-xue

Any updates on this?

VeryEarly commented 4 years ago

Hi @jonarmstrong ,

I tried to reproduce this and found there are no headers in the request I sent, submitted issue to dotnet sdk: https://github.com/Azure/azure-sdk-for-net/issues/13472

Will keep you up-to-date once I found the cause.

Thanks

jonarmstrong commented 4 years ago

@VeryEarly, thank you for looking into this.

HaikoHertes commented 1 year ago

The issue still exists as of today using latest PowerShell and Azure Modules. Any updates?