Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions setup/azurecmd.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
<RegistrySearch Id="PSCOMPATIBLEVERSION" Root="HKLM" Key="SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine" Name="PSCompatibleVersion" Type="raw" />
</Property>

<SetProperty Action="SetBase64" Id="BaseModulesFolder" Value="[ProgramFiles64Folder]WindowsPowerShell\Modules" Before="AppSearch">
<SetProperty Action="SetBase64" Id="BaseModulesFolder" Value="[ProgramFiles64Folder]WindowsPowerShell\Modules\" Before="AppSearch">
VersionNT64
</SetProperty>

<SetProperty Action="SetBase32" Id="BaseModulesFolder" Value="[ProgramFilesFolder]WindowsPowerShell\Modules" Before="AppSearch">
<SetProperty Action="SetBase32" Id="BaseModulesFolder" Value="[ProgramFilesFolder]WindowsPowerShell\Modules\" Before="AppSearch">
NOT VersionNT64
</SetProperty>

Expand Down Expand Up @@ -81,7 +81,7 @@
<Component Id="PSModulePath.System" Guid="273525B9-7AAB-421A-90C8-8E50A1840B8D">
<CreateFolder />
<!-- Work around bug that PowerShell does not always consider default module paths. -->
<Environment Id="PSModulePath.SystemAppRoot" Action="set" Name="PSMODULEPATH" Part="last" Value="[BaseModulesFolder];[PowerShellFolder]ResourceManager\AzureResourceManager;[PowerShellFolder]ServiceManagement" System="yes" />
<Environment Id="PSModulePath.SystemAppRoot" Action="set" Name="PSMODULEPATH" Part="last" Value="[BaseModulesFolder];[PowerShellFolder]ResourceManager\AzureResourceManager\;[PowerShellFolder]ServiceManagement\" System="yes" />
</Component>
</DirectoryRef>

Expand Down
7 changes: 7 additions & 0 deletions src/Common/Commands.Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
using System.Text;
using System.Linq;
using System.Threading;
using Microsoft.Rest;

namespace Microsoft.WindowsAzure.Commands.Utilities.Common
{
Expand All @@ -40,6 +41,9 @@ public abstract class AzurePSCmdlet : PSCmdlet, IDisposable
private RecordingTracingInterceptor _httpTracingInterceptor;

private DebugStreamTraceListener _adalListener;

private ServiceClientTracingInterceptor _serviceClientTracingInterceptor;

protected static AzurePSDataCollectionProfile _dataCollectionProfile = null;
protected static string _errorRecordFolderPath = null;
protected const string _fileTimeStampSuffixFormat = "yyyy-MM-dd-THH-mm-ss-fff";
Expand Down Expand Up @@ -216,8 +220,10 @@ protected override void BeginProcessing()

_httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages);
_adalListener = _adalListener ?? new DebugStreamTraceListener(_debugMessages);
_serviceClientTracingInterceptor = _serviceClientTracingInterceptor ?? new ServiceClientTracingInterceptor(_debugMessages);
RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
DebugStreamTraceListener.AddAdalTracing(_adalListener);
ServiceClientTracing.AddTracingInterceptor(_serviceClientTracingInterceptor);

ProductInfoHeaderValue userAgentValue = new ProductInfoHeaderValue(
ModuleName, string.Format("v{0}", ModuleVersion));
Expand All @@ -237,6 +243,7 @@ protected override void EndProcessing()

RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
ServiceClientTracingInterceptor.RemoveTracingInterceptor(_serviceClientTracingInterceptor);
FlushDebugMessages();

AzureSession.ClientFactory.UserAgents.RemoveWhere(u => u.Product.Name == ModuleName);
Expand Down
1 change: 1 addition & 0 deletions src/Common/Commands.Common/Commands.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
<Compile Include="ProfileClientExtensions.cs" />
<Compile Include="ClientCreatedArgs.cs" />
<Compile Include="CmdletExtensions.cs" />
<Compile Include="ServiceClientTracingInterceptor.cs" />
<Compile Include="TestMockSupport.cs" />
<Compile Include="PSAzureAccount.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
80 changes: 80 additions & 0 deletions src/Common/Commands.Common/ServiceClientTracingInterceptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Rest;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.WindowsAzure.Commands.Common
{
class ServiceClientTracingInterceptor : IServiceClientTracingInterceptor
{
public ServiceClientTracingInterceptor(ConcurrentQueue<string> queue)
{
MessageQueue = queue;
}

public ConcurrentQueue<string> MessageQueue { get; private set; }

public void Configuration(string source, string name, string value)
{
// Ignore
}

public void EnterMethod(string invocationId, object instance, string method, IDictionary<string, object> parameters)
{
// Ignore
}

public void ExitMethod(string invocationId, object returnValue)
{
// Ignore
}

public void Information(string message)
{
MessageQueue.Enqueue(message);
}

public void ReceiveResponse(string invocationId, System.Net.Http.HttpResponseMessage response)
{
string responseAsString = response == null ? string.Empty : response.AsFormattedString();
MessageQueue.Enqueue(responseAsString);
}

public void SendRequest(string invocationId, System.Net.Http.HttpRequestMessage request)
{
string requestAsString = request == null ? string.Empty : request.AsFormattedString();
MessageQueue.Enqueue(requestAsString);
}

public void TraceError(string invocationId, Exception exception)
{
// Ignore
}

public static void RemoveTracingInterceptor(ServiceClientTracingInterceptor interceptor)
{
if (interceptor != null)
{
ServiceClientTracing.RemoveTracingInterceptor(interceptor);
}
}
}
}