Skip to content

Commit 4f5dd00

Browse files
author
Hovsep Mkrtchyan
committed
Merge branch 'dev' of github.com:Azure/azure-powershell into dev
Conflicts: tools/AzureRM/AzureRM.psm1
2 parents b083a01 + 3fade8b commit 4f5dd00

File tree

5 files changed

+100
-9
lines changed

5 files changed

+100
-9
lines changed

setup/azurecmd.wxs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
<RegistrySearch Id="PSCOMPATIBLEVERSION" Root="HKLM" Key="SOFTWARE\Microsoft\PowerShell\3\PowerShellEngine" Name="PSCompatibleVersion" Type="raw" />
3232
</Property>
3333

34-
<SetProperty Action="SetBase64" Id="BaseModulesFolder" Value="[ProgramFiles64Folder]WindowsPowerShell\Modules" Before="AppSearch">
34+
<SetProperty Action="SetBase64" Id="BaseModulesFolder" Value="[ProgramFiles64Folder]WindowsPowerShell\Modules\" Before="AppSearch">
3535
VersionNT64
3636
</SetProperty>
3737

38-
<SetProperty Action="SetBase32" Id="BaseModulesFolder" Value="[ProgramFilesFolder]WindowsPowerShell\Modules" Before="AppSearch">
38+
<SetProperty Action="SetBase32" Id="BaseModulesFolder" Value="[ProgramFilesFolder]WindowsPowerShell\Modules\" Before="AppSearch">
3939
NOT VersionNT64
4040
</SetProperty>
4141

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

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
using System.Text;
2828
using System.Linq;
2929
using System.Threading;
30+
using Microsoft.Rest;
3031

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

4243
private DebugStreamTraceListener _adalListener;
44+
45+
private ServiceClientTracingInterceptor _serviceClientTracingInterceptor;
46+
4347
protected static AzurePSDataCollectionProfile _dataCollectionProfile = null;
4448
protected static string _errorRecordFolderPath = null;
4549
protected const string _fileTimeStampSuffixFormat = "yyyy-MM-dd-THH-mm-ss-fff";
@@ -216,8 +220,10 @@ protected override void BeginProcessing()
216220

217221
_httpTracingInterceptor = _httpTracingInterceptor ?? new RecordingTracingInterceptor(_debugMessages);
218222
_adalListener = _adalListener ?? new DebugStreamTraceListener(_debugMessages);
223+
_serviceClientTracingInterceptor = _serviceClientTracingInterceptor ?? new ServiceClientTracingInterceptor(_debugMessages);
219224
RecordingTracingInterceptor.AddToContext(_httpTracingInterceptor);
220225
DebugStreamTraceListener.AddAdalTracing(_adalListener);
226+
ServiceClientTracing.AddTracingInterceptor(_serviceClientTracingInterceptor);
221227

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

238244
RecordingTracingInterceptor.RemoveFromContext(_httpTracingInterceptor);
239245
DebugStreamTraceListener.RemoveAdalTracing(_adalListener);
246+
ServiceClientTracingInterceptor.RemoveTracingInterceptor(_serviceClientTracingInterceptor);
240247
FlushDebugMessages();
241248

242249
AzureSession.ClientFactory.UserAgents.RemoveWhere(u => u.Product.Name == ModuleName);

src/Common/Commands.Common/Commands.Common.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@
170170
<Compile Include="ProfileClientExtensions.cs" />
171171
<Compile Include="ClientCreatedArgs.cs" />
172172
<Compile Include="CmdletExtensions.cs" />
173+
<Compile Include="ServiceClientTracingInterceptor.cs" />
173174
<Compile Include="TestMockSupport.cs" />
174175
<Compile Include="PSAzureAccount.cs" />
175176
<Compile Include="Properties\AssemblyInfo.cs" />
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using Microsoft.Rest;
16+
using System;
17+
using System.Collections.Concurrent;
18+
using System.Collections.Generic;
19+
using System.Diagnostics;
20+
using System.Linq;
21+
using System.Text;
22+
using System.Threading.Tasks;
23+
24+
namespace Microsoft.WindowsAzure.Commands.Common
25+
{
26+
class ServiceClientTracingInterceptor : IServiceClientTracingInterceptor
27+
{
28+
public ServiceClientTracingInterceptor(ConcurrentQueue<string> queue)
29+
{
30+
MessageQueue = queue;
31+
}
32+
33+
public ConcurrentQueue<string> MessageQueue { get; private set; }
34+
35+
public void Configuration(string source, string name, string value)
36+
{
37+
// Ignore
38+
}
39+
40+
public void EnterMethod(string invocationId, object instance, string method, IDictionary<string, object> parameters)
41+
{
42+
// Ignore
43+
}
44+
45+
public void ExitMethod(string invocationId, object returnValue)
46+
{
47+
// Ignore
48+
}
49+
50+
public void Information(string message)
51+
{
52+
MessageQueue.Enqueue(message);
53+
}
54+
55+
public void ReceiveResponse(string invocationId, System.Net.Http.HttpResponseMessage response)
56+
{
57+
string responseAsString = response == null ? string.Empty : response.AsFormattedString();
58+
MessageQueue.Enqueue(responseAsString);
59+
}
60+
61+
public void SendRequest(string invocationId, System.Net.Http.HttpRequestMessage request)
62+
{
63+
string requestAsString = request == null ? string.Empty : request.AsFormattedString();
64+
MessageQueue.Enqueue(requestAsString);
65+
}
66+
67+
public void TraceError(string invocationId, Exception exception)
68+
{
69+
// Ignore
70+
}
71+
72+
public static void RemoveTracingInterceptor(ServiceClientTracingInterceptor interceptor)
73+
{
74+
if (interceptor != null)
75+
{
76+
ServiceClientTracing.RemoveTracingInterceptor(interceptor);
77+
}
78+
}
79+
}
80+
}

tools/AzureRM/AzureRM.psm1

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function CheckIncompatibleVersion([bool]$Force)
6767
}
6868
}
6969

70-
function Install-ModuleWithVersionCheck([string]$Name,[string]$MinimumVersion,[string]$Repository,[string]$Scope)
70+
function Install-ModuleWithVersionCheck([string]$Name,[string]$MinimumVersion,[string]$Repository,[string]$Scope,[switch]$Force)
7171
{
7272
$_MinVer = $MinimumVersion
7373
$_MaxVer = "$($_MinVer.Split(".")[0]).9999.0"
@@ -77,7 +77,7 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MinimumVersion,[s
7777
$_ModuleAction = "installed"
7878
if ($_ExistingModule -ne $null)
7979
{
80-
Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Force -ErrorAction Stop
80+
Install-Module -Name $Name -Repository $Repository -Scope $Scope -MinimumVersion $_MinVer -MaximumVersion $_MaxVer -Force:$force -ErrorAction Stop
8181
$_ModuleAction = "updated"
8282
}
8383
else
@@ -107,6 +107,9 @@ function Install-ModuleWithVersionCheck([string]$Name,[string]$MinimumVersion,[s
107107
108108
.Parameter Scope
109109
Specifies the parameter scope.
110+
111+
.Parameter Force
112+
Force download and installation of modules already installed.
110113
#>
111114
function Update-AzureRM
112115
{
@@ -137,17 +140,17 @@ function Update-AzureRM
137140
{
138141
Set-PSRepository -Name $Repository -InstallationPolicy Trusted
139142

140-
# Update Profile and Storage
141-
Install-ModuleWithVersionCheck "AzureRM.Profile" $AzureRMDependencies["AzureRM.Profile"] $Repository $Scope
142-
Install-ModuleWithVersionCheck "Azure.Storage" $AzureRMDependencies["Azure.Storage"] $Repository $Scope
143+
# Update Profile and Storage
144+
Install-ModuleWithVersionCheck "AzureRM.Profile" $AzureRMDependencies["AzureRM.Profile"] $Repository $Scope -Force:$force
145+
Install-ModuleWithVersionCheck "Azure.Storage" $AzureRMDependencies["Azure.Storage"] $Repository $Scope -Force:$force
143146

144147
# Start new job
145148
$AzureRMModules.Keys | ForEach {
146149
$_MinVer = $MinVersion
147150
if(!$MinVersion) {
148151
$_MinVer = $AzureRMModules[$_]
149152
}
150-
Install-ModuleWithVersionCheck $_ $_MinVer $Repository $Scope
153+
Install-ModuleWithVersionCheck $_ $_MinVer $Repository $Scope -Force:$force
151154
}
152155
} finally {
153156
# Clean up

0 commit comments

Comments
 (0)