diff --git a/src/ContainerInstance/custom/InvokeAzContainerInstanceCommand_ExecuteExpanded.cs b/src/ContainerInstance/custom/InvokeAzContainerInstanceCommand_ExecuteExpanded.cs index 6aebe8b82b04..4a2a6cbedc25 100644 --- a/src/ContainerInstance/custom/InvokeAzContainerInstanceCommand_ExecuteExpanded.cs +++ b/src/ContainerInstance/custom/InvokeAzContainerInstanceCommand_ExecuteExpanded.cs @@ -71,13 +71,15 @@ private Task PullResponse() if (!string.IsNullOrEmpty(result) && PassThru.ToBool()) { WriteObject(result.TrimEnd()); } - }, this._cancellationTokenSource.Token); + }, this._cancellationTokenSource.Token).Unwrap(); } private Task PushCommand() { return Task.Factory.StartNew(async () => { + if (Console.IsInputRedirected) return; + StringBuilder input = new StringBuilder(); // Loop until input is entered. while (socket.State == WebSocketState.Open && !this._cancellationTokenSource.Token.IsCancellationRequested) @@ -95,7 +97,7 @@ private Task PushCommand() System.Threading.Thread.Sleep(250); } - }, this._cancellationTokenSource.Token); + }, this._cancellationTokenSource.Token).Unwrap(); } }