20
20
using System . Management . Automation ;
21
21
using System . Net ;
22
22
using Microsoft . Azure . Commands . Common . Authentication . Abstractions ;
23
+ using System . Threading ;
24
+ using Microsoft . WindowsAzure . Commands . Utilities . Common ;
23
25
24
26
namespace Microsoft . Azure . Commands . OperationalInsights . Query
25
27
{
@@ -28,6 +30,7 @@ public class InvokeOperationalInsightsQuery : ResourceManager.Common.AzureRmLong
28
30
{
29
31
private const string ParamSetNameByWorkspaceId = "ByWorkspaceId" ;
30
32
private const string ParamSetNameByWorkspaceObject = "ByWorkspaceObject" ;
33
+ private readonly double _timeoutBufferInSeconds = 30 ;
31
34
32
35
[ Parameter ( Mandatory = true , ParameterSetName = ParamSetNameByWorkspaceId , HelpMessage = "The workspace ID." ) ]
33
36
[ ValidateNotNullOrEmpty ]
@@ -73,11 +76,13 @@ internal OperationalInsightsDataClient OperationalInsightsDataClient
73
76
74
77
this . _operationalInsightsDataClient =
75
78
AzureSession . Instance . ClientFactory . CreateCustomArmClient < OperationalInsightsDataClient > ( clientCredentials ) ;
79
+ ConfigureTimeoutForClient ( ) ;
80
+
76
81
this . _operationalInsightsDataClient . Preferences . IncludeRender = IncludeRender . IsPresent ;
77
82
this . _operationalInsightsDataClient . Preferences . IncludeStatistics = IncludeStatistics . IsPresent ;
78
83
this . _operationalInsightsDataClient . NameHeader = "LogAnalyticsPSClient" ;
79
84
80
- Uri targetUri = null ;
85
+ Uri targetUri = null ;
81
86
DefaultContext . Environment . TryGetEndpointUrl (
82
87
AzureEnvironment . ExtendedEndpoint . OperationalInsightsEndpoint , out targetUri ) ;
83
88
if ( targetUri == null )
@@ -101,6 +106,14 @@ internal OperationalInsightsDataClient OperationalInsightsDataClient
101
106
}
102
107
}
103
108
109
+ private void ConfigureTimeoutForClient ( )
110
+ {
111
+ if ( this . IsParameterBound ( c => c . Wait ) && Wait != null )
112
+ {
113
+ _operationalInsightsDataClient . HttpClient . Timeout = TimeSpan . FromSeconds ( Convert . ToDouble ( Wait ) ) . Add ( TimeSpan . FromSeconds ( _timeoutBufferInSeconds ) ) ;
114
+ }
115
+ }
116
+
104
117
public override void ExecuteCmdlet ( )
105
118
{
106
119
if ( ParameterSetName == ParamSetNameByWorkspaceId )
0 commit comments