Skip to content

Commit 9dc41f5

Browse files
committed
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
# Conflicts: # setup/azurecmdfiles.wxi
2 parents a018b7d + e51c883 commit 9dc41f5

File tree

165 files changed

+3019
-505
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+3019
-505
lines changed

setup/azurecmdfiles.wxi

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,9 @@
980980
<Component Id="cmpA0007735AC9E1F08D542DFB279E586D8" Guid="*">
981981
<File Id="fil01D736AF28D556A08BEC46052977A312" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Dns\Microsoft.Azure.Common.dll" />
982982
</Component>
983+
<Component Id="cmpA57D9B2B1FA9DFC84A81E3854A2CB87C" Guid="*">
984+
<File Id="fil032AAADDE56C235AAB8CBEC6D7A16884" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Dns\Microsoft.Azure.Common.NetFramework.dll" />
985+
</Component>
983986
<Component Id="cmpB3134BB8ADC109CD66C73AB4AC43FF8A" Guid="*">
984987
<File Id="filA97E787A98E4BD2B9966B260AEA3DB26" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Dns\Microsoft.Azure.Management.Authorization.dll" />
985988
</Component>
@@ -989,6 +992,9 @@
989992
<Component Id="cmp2F8A21B67A574848E46161AF4DBAEAB7" Guid="*">
990993
<File Id="filF14443EF28F6FBDB30559A1428F6CE5A" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Dns\Microsoft.Azure.ResourceManager.dll" />
991994
</Component>
995+
<Component Id="cmpFD0DE325B243453297C251C92C98245D" Guid="*">
996+
<File Id="fil4FFFA196C05E15050769FA034FB3EE9E" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Dns\Microsoft.Data.Services.Client.dll" />
997+
</Component>
992998
<Component Id="cmp5B16E8141BC633DB9DEB2A9361AF4C71" Guid="*">
993999
<File Id="fil053D4ECE5C90FA22AC3747457B5DBB3D" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.Dns\Microsoft.IdentityModel.Clients.ActiveDirectory.dll" />
9941000
</Component>
@@ -1814,12 +1820,6 @@
18141820
<Component Id="cmpB77BD825E0EE360848A0E312174B8E79" Guid="*">
18151821
<File Id="filC946540561EFB51E32A9A78C9A4C4E4E" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RedisCache\Microsoft.Azure.ResourceManager.dll" />
18161822
</Component>
1817-
<Component Id="cmpB1AB5620182396F5055594CB5B71DFF5" Guid="*">
1818-
<File Id="fil927418DCA437A44F331156F1B181B0CB" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RedisCache\Microsoft.Data.Edm.dll" />
1819-
</Component>
1820-
<Component Id="cmpF3A6E2A588E2828B1141B2B4F2DEE2CA" Guid="*">
1821-
<File Id="fil6885A1C5198BBE4BE218B29F4AF8CD4F" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RedisCache\Microsoft.Data.OData.dll" />
1822-
</Component>
18231823
<Component Id="cmpDFF1A711321C50653141E2AE4BB76806" Guid="*">
18241824
<File Id="filF25C5E7B600CD1857B7B71EF4B86B617" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.RedisCache\Microsoft.Data.Services.Client.dll" />
18251825
</Component>
@@ -2533,6 +2533,9 @@
25332533
<Component Id="cmp12BBC947AD240DEE262EA093791B4CFD" Guid="*">
25342534
<File Id="fil278854BEDEA8FF5856C0538AEF2C651A" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.TrafficManager\Microsoft.Azure.Common.dll" />
25352535
</Component>
2536+
<Component Id="cmp4082D5B2D1FF8772A47657154A994C1B" Guid="*">
2537+
<File Id="fil3A8FA25253954FC962A3D35C634BC4A1" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.TrafficManager\Microsoft.Azure.Common.NetFramework.dll" />
2538+
</Component>
25362539
<Component Id="cmp754B6BD77C6EC782EB88981DAFD35510" Guid="*">
25372540
<File Id="fil9C8B0B0929FDD1386F40C7E26D5A8620" KeyPath="yes" Source="$(var.sourceDir)\ResourceManager\AzureResourceManager\AzureRM.TrafficManager\Microsoft.Azure.Management.TrafficManager.dll" />
25382541
</Component>
@@ -5076,9 +5079,11 @@
50765079
<ComponentRef Id="cmpC239A907B911A2FE5AC4C3DFF236F154" />
50775080
<ComponentRef Id="cmp4B300B78CE6E09D004B7EF084792169B" />
50785081
<ComponentRef Id="cmpA0007735AC9E1F08D542DFB279E586D8" />
5082+
<ComponentRef Id="cmpA57D9B2B1FA9DFC84A81E3854A2CB87C" />
50795083
<ComponentRef Id="cmpB3134BB8ADC109CD66C73AB4AC43FF8A" />
50805084
<ComponentRef Id="cmp23A4C42E03D6ADC61C13AED7A3C5C43D" />
50815085
<ComponentRef Id="cmp2F8A21B67A574848E46161AF4DBAEAB7" />
5086+
<ComponentRef Id="cmpFD0DE325B243453297C251C92C98245D" />
50825087
<ComponentRef Id="cmp5B16E8141BC633DB9DEB2A9361AF4C71" />
50835088
<ComponentRef Id="cmp24741C738CAC6E0595C4035CF8FE190A" />
50845089
<ComponentRef Id="cmpB21325D18CF34CB53A2C33585CE3C81B" />
@@ -5348,8 +5353,6 @@
53485353
<ComponentRef Id="cmpE542A66FF253AB7ECF153BC7F8617497" />
53495354
<ComponentRef Id="cmp3A5E7F3EA44ACFDD84B8CE1D36DA80C7" />
53505355
<ComponentRef Id="cmpB77BD825E0EE360848A0E312174B8E79" />
5351-
<ComponentRef Id="cmpB1AB5620182396F5055594CB5B71DFF5" />
5352-
<ComponentRef Id="cmpF3A6E2A588E2828B1141B2B4F2DEE2CA" />
53535356
<ComponentRef Id="cmpDFF1A711321C50653141E2AE4BB76806" />
53545357
<ComponentRef Id="cmpD5D6E28B9232D19A4D3FC543B56214DB" />
53555358
<ComponentRef Id="cmp6DCD11F46E1DCE998C423CD0BC09CD15" />
@@ -5583,6 +5586,7 @@
55835586
<ComponentRef Id="cmp0B156F82D73453E7932C459CED906BC3" />
55845587
<ComponentRef Id="cmp79A47006BA0B7E3D64E4815604275F77" />
55855588
<ComponentRef Id="cmp12BBC947AD240DEE262EA093791B4CFD" />
5589+
<ComponentRef Id="cmp4082D5B2D1FF8772A47657154A994C1B" />
55865590
<ComponentRef Id="cmp754B6BD77C6EC782EB88981DAFD35510" />
55875591
<ComponentRef Id="cmp32DFA22F02C3F2327513E517FC7A3BC9" />
55885592
<ComponentRef Id="cmpB86658F355E269A5F3E9B9220D5CAC57" />

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,15 @@
7575
<SpecificVersion>False</SpecificVersion>
7676
<HintPath>..\..\packages\Microsoft.Azure.Management.Resources.2.18.7-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
7777
</Reference>
78-
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
78+
<Reference Include="Microsoft.Data.Edm">
7979
<SpecificVersion>False</SpecificVersion>
8080
<HintPath>..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
8181
</Reference>
82-
<Reference Include="Microsoft.Data.OData, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
82+
<Reference Include="Microsoft.Data.OData">
8383
<SpecificVersion>False</SpecificVersion>
8484
<HintPath>..\..\packages\Microsoft.Data.OData.5.6.4\lib\net40\Microsoft.Data.OData.dll</HintPath>
8585
</Reference>
86-
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
86+
<Reference Include="Microsoft.Data.Services.Client">
8787
<SpecificVersion>False</SpecificVersion>
8888
<HintPath>..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
8989
</Reference>
@@ -111,9 +111,9 @@
111111
<SpecificVersion>False</SpecificVersion>
112112
<HintPath>..\..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
113113
</Reference>
114-
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=2.0.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
114+
<Reference Include="Microsoft.WindowsAzure.Configuration">
115115
<SpecificVersion>False</SpecificVersion>
116-
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.2.0.3\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
116+
<HintPath>..\..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.3.2.0\lib\net40\Microsoft.WindowsAzure.Configuration.dll</HintPath>
117117
</Reference>
118118
<Reference Include="Microsoft.WindowsAzure.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
119119
<SpecificVersion>False</SpecificVersion>

src/Common/Commands.Common.Storage/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<package id="Microsoft.Net.Http" version="2.2.28" targetFramework="net45" />
1818
<package id="Microsoft.Rest.ClientRuntime" version="1.8.2" targetFramework="net45" />
1919
<package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="0.11.0" targetFramework="net45" />
20-
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net45" />
20+
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="3.2.0" targetFramework="net45" />
2121
<package id="Microsoft.WindowsAzure.Management" version="4.1.1" targetFramework="net45" />
2222
<package id="Microsoft.WindowsAzure.Management.Storage" version="5.1.1" targetFramework="net45" />
2323
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net45" />

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
using System.Linq;
2929
using System.Threading;
3030
using Microsoft.Rest;
31+
using Microsoft.ApplicationInsights;
3132

3233
namespace Microsoft.WindowsAzure.Commands.Utilities.Common
3334
{
@@ -46,12 +47,15 @@ public abstract class AzurePSCmdlet : PSCmdlet, IDisposable
4647

4748
protected static AzurePSDataCollectionProfile _dataCollectionProfile = null;
4849
protected static string _errorRecordFolderPath = null;
49-
protected const string _fileTimeStampSuffixFormat = "yyyy-MM-dd-THH-mm-ss-fff";
50+
protected static string _sessionId = Guid.NewGuid().ToString();
51+
protected const string _fileTimeStampSuffixFormat = "yyyy-MM-dd-THH-mm-ss-fff";
52+
protected string _clientRequestId = Guid.NewGuid().ToString();
53+
protected MetricHelper _metricHelper;
5054

5155
protected AzurePSQoSEvent QosEvent;
5256

5357
protected virtual bool IsUsageMetricEnabled {
54-
get { return false; }
58+
get { return true; }
5559
}
5660

5761
protected virtual bool IsErrorMetricEnabled
@@ -61,7 +65,7 @@ protected virtual bool IsErrorMetricEnabled
6165

6266
/// <summary>
6367
/// Gets the PowerShell module name used for user agent header.
64-
/// By default uses "Azurepowershell"
68+
/// By default uses "Azure PowerShell"
6569
/// </summary>
6670
protected virtual string ModuleName { get { return "AzurePowershell"; } }
6771

@@ -81,6 +85,13 @@ protected virtual bool IsErrorMetricEnabled
8185
public AzurePSCmdlet()
8286
{
8387
_debugMessages = new ConcurrentQueue<string>();
88+
89+
//TODO: Inject from CI server
90+
_metricHelper = new MetricHelper();
91+
_metricHelper.AddTelemetryClient(new TelemetryClient
92+
{
93+
InstrumentationKey = "7df6ff70-8353-4672-80d6-568517fed090"
94+
});
8495
}
8596

8697
/// <summary>
@@ -228,7 +239,7 @@ protected override void BeginProcessing()
228239
ProductInfoHeaderValue userAgentValue = new ProductInfoHeaderValue(
229240
ModuleName, string.Format("v{0}", ModuleVersion));
230241
AzureSession.ClientFactory.UserAgents.Add(userAgentValue);
231-
AzureSession.ClientFactory.AddHandler(new CmdletInfoHandler(this.CommandRuntime.ToString(), this.ParameterSetName));
242+
AzureSession.ClientFactory.AddHandler(new CmdletInfoHandler(this.CommandRuntime.ToString(), this.ParameterSetName, this._clientRequestId));
232243
base.BeginProcessing();
233244
}
234245

@@ -253,7 +264,7 @@ protected override void EndProcessing()
253264

254265
protected string CurrentPath()
255266
{
256-
// SessionState is only available within Powershell so default to
267+
// SessionState is only available within PowerShell so default to
257268
// the CurrentDirectory when being run from tests.
258269
return (SessionState != null) ?
259270
SessionState.Path.CurrentLocation.Path :
@@ -273,7 +284,6 @@ protected bool IsVerbose()
273284
{
274285
QosEvent.Exception = errorRecord.Exception;
275286
QosEvent.IsSuccess = false;
276-
LogQosEvent(true);
277287
}
278288

279289
base.WriteError(errorRecord);
@@ -438,7 +448,7 @@ private void RecordDebugMessages()
438448
/// <summary>
439449
/// Invoke this method when the cmdlet is completed or terminated.
440450
/// </summary>
441-
protected void LogQosEvent(bool waitForMetricSending = false)
451+
protected void LogQosEvent()
442452
{
443453
if (QosEvent == null)
444454
{
@@ -461,8 +471,8 @@ protected void LogQosEvent(bool waitForMetricSending = false)
461471

462472
try
463473
{
464-
MetricHelper.LogQoSEvent(QosEvent, IsUsageMetricEnabled, IsErrorMetricEnabled);
465-
MetricHelper.FlushMetric(waitForMetricSending);
474+
_metricHelper.LogQoSEvent(QosEvent, IsUsageMetricEnabled, IsErrorMetricEnabled);
475+
_metricHelper.FlushMetric();
466476
WriteDebug("Finish sending metric.");
467477
}
468478
catch (Exception e)

src/Common/Commands.Common/CmdletInfoHandler.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,23 @@ public class CmdletInfoHandler : DelegatingHandler, ICloneable
3333
/// The name of the parameter set specified by user.
3434
/// </summary>
3535
public string ParameterSet { get; private set; }
36+
37+
/// <summary>
38+
/// The unique client request id.
39+
/// </summary>
40+
public string ClientRequestId { get; private set; }
3641

3742
/// <summary>
3843
/// Initializes an instance of a CmdletInfoHandler with the name of the cmdlet and the parameter set.
3944
/// </summary>
4045
/// <param name="cmdlet">the name of the cmdlet</param>
4146
/// <param name="parameterSet">the name of the parameter set specified by user</param>
42-
public CmdletInfoHandler(string cmdlet, string parameterSet)
47+
/// <param name="clientRequestId">the unique clientRequestId</param>
48+
public CmdletInfoHandler(string cmdlet, string parameterSet, string clientRequestId)
4349
{
4450
this.Cmdlet = cmdlet;
4551
this.ParameterSet = parameterSet;
52+
this.ClientRequestId = clientRequestId;
4653
}
4754

4855
protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
@@ -55,12 +62,20 @@ protected override Task<HttpResponseMessage> SendAsync(HttpRequestMessage reques
5562
{
5663
request.Headers.Add("ParameterSetName", ParameterSet);
5764
}
65+
if (ClientRequestId != null)
66+
{
67+
if (request.Headers.Contains("x-ms-client-request-id"))
68+
{
69+
request.Headers.Remove("x-ms-client-request-id");
70+
}
71+
request.Headers.TryAddWithoutValidation("x-ms-client-request-id", ClientRequestId);
72+
}
5873
return base.SendAsync(request, cancellationToken);
5974
}
6075

6176
public object Clone()
6277
{
63-
return new CmdletInfoHandler(this.Cmdlet, this.ParameterSet);
78+
return new CmdletInfoHandler(this.Cmdlet, this.ParameterSet, this.ClientRequestId);
6479
}
6580
}
6681
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
<Private>True</Private>
108108
</Reference>
109109
<Reference Include="Newtonsoft.Json">
110-
<HintPath>..\..\packages\Newtonsoft.Json.6.0.4\lib\net45\Newtonsoft.Json.dll</HintPath>
110+
<HintPath>..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll</HintPath>
111111
<Private>True</Private>
112112
</Reference>
113113
<Reference Include="System" />

0 commit comments

Comments
 (0)