Skip to content

Release 0.9.8 #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 64 commits into from
Sep 10, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
b095fb7
Merge branch 'master' of https://github.com/Azure/azure-powershell-pr
robertla Apr 10, 2015
4284699
Merge branch 'master' of https://github.com/Azure/azure-powershell
robertla Apr 10, 2015
e0f24ce
bug:1778355 Desktop Support/Add paging for SP
robertla Apr 13, 2015
1bd4cd8
bug:1778355 Desktop Support/Add paging for SP
robertla Apr 13, 2015
a90b9c7
Merge branch 'ChunkedSP' into CITest bad merge deleting file and merg…
robertla Apr 23, 2015
f4b2cbc
bug:1778355 Desktop Support/Add paging for SP
robertla Apr 23, 2015
b188115
Adding Check-In Test to ARA
robertla Apr 24, 2015
d52ef02
Adding Checkin Tests to Azure RemoteApp
robertla Apr 29, 2015
b4f2ab9
Adding Checkin Tests to Azure RemoteApp
robertla May 5, 2015
cff97c6
Adding Checkin Tests to Azure RemoteApp
robertla May 5, 2015
67c965f
Merge branch 'dev' of https://github.com/robertla/azure-powershell in…
robertla May 6, 2015
251e17d
Adding Checkin Tests to Azure RemoteApp
robertla May 6, 2015
aaf9c36
Adding Checkin Tests to Azure RemoteApp
robertla May 15, 2015
9da648c
Merging from Azure/Dev
robertla May 20, 2015
dd530ef
Backing out Paged User code
robertla May 28, 2015
2b8afa5
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
robertla Jun 1, 2015
371f96e
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
robertla Jun 8, 2015
0045bef
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
robertla Jul 12, 2015
7101f23
Removing AD requirement for VNets
robertla Jul 15, 2015
393b299
Merge branch 'master' of https://github.com/Azure/azure-powershell in…
robertla Aug 4, 2015
8e57dd8
Deprecating VNets
robertla Aug 6, 2015
10abbe7
SQL Server Virtual Machine Azure Key Vault Integration
Aug 8, 2015
41bf97c
Updating code based off of the review
robertla Aug 10, 2015
edbc5c8
Updating code based off of the review
robertla Aug 10, 2015
c80ee5d
Merge branch 'RemoteApp' of https://github.com/robertla/azure-powersh…
robertla Aug 10, 2015
6c18a04
Merge branch 'master' of https://github.com/Azure/azure-powershell
robertla Aug 10, 2015
a108bd8
Merge branch 'RemoteApp' of https://github.com/robertla/azure-powersh…
robertla Aug 10, 2015
a0473e0
Don't use default settings when settings are missing
Aug 11, 2015
c8658ea
SQL Server IaaS Extension cmdlets update
Aug 14, 2015
3d0f59b
This is update to local branch
Aug 14, 2015
28b5a2b
Merge branch 'Azure-dev' into dev
Aug 14, 2015
e7ac8cb
Merge branch 'master' of https://github.com/Azure/azure-powershell
robertla Aug 17, 2015
24875b7
Removing Scenario test
robertla Aug 17, 2015
72b8faf
Merge branch 'master' of https://github.com/Azure/azure-powershell
robertla Aug 19, 2015
275f5ca
Merge branch 'master' of https://github.com/Azure/azure-powershell
robertla Aug 24, 2015
54b8681
Merge branch 'master' of https://github.com/Azure/azure-powershell in…
robertla Aug 28, 2015
1721dc2
Updateing local branch
Aug 29, 2015
fb38b57
Merge branch 'master' of https://github.com/robertla/azure-powershell
robertla Sep 1, 2015
16fca57
Merge branch 'master' into RDFE_RemoteApp
robertla Sep 1, 2015
44ef696
Merge branch 'dev' into Azure/release-0.9.8
Sep 3, 2015
8e8ab7a
Adding file deleted by mistake. Adding the same file from the head br…
Sep 4, 2015
af71940
Merge branch 'master' into RDFE_RemoteApp
robertla Sep 1, 2015
8935f84
Merge branch 'RDFE_RemoteApp' of https://github.com/robertla/azure-po…
robertla Sep 4, 2015
50312c1
Merge pull request #847 from OJDUDE/release-0.9.8
Sep 4, 2015
3561532
Merge pull request #856 from huangpf/r098
Sep 4, 2015
7360d6b
Add usage log in metric helper
xindzhan Jul 15, 2015
7b3ac7d
Add AzureQoSEvent
xindzhan Jul 17, 2015
f2fb746
Switch to internal test account and enable IP metrics for now
xindzhan Jul 17, 2015
841eee4
Split usage/err enable flag
xindzhan Jul 22, 2015
a5f1772
Add skip condition to LogQosEvent
xindzhan Jul 22, 2015
bb69777
Fix test fail in ActionConfirm
xindzhan Jul 29, 2015
6fe2350
Add timeout to AI flush
xindzhan Jul 31, 2015
3cbf161
remove debug tests
Sep 3, 2015
91251af
updating refs
Sep 4, 2015
f85fb6b
add warning to ASM cmdlets
Aug 28, 2015
8bc7b7d
Merge pull request #861 from robertla/RDFE_RemoteApp
Sep 4, 2015
703907b
remove app.config
Sep 8, 2015
2ba6cad
Merge pull request #862 from shefaliv/dev
Sep 8, 2015
42360a1
Integrate with opt in/out cmdlets
xindzhan Sep 8, 2015
7a61084
Merge pull request #869 from xindzhan/ai
Sep 9, 2015
d50833f
Add wix file for AI dll
xindzhan Sep 9, 2015
0330b5f
Merge pull request #872 from xindzhan/ai
Sep 9, 2015
2059005
Fix storage test for QosEvent writeError
xindzhan Sep 9, 2015
93162be
Merge pull request #875 from xindzhan/ai
Sep 9, 2015
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
156 changes: 156 additions & 0 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

104 changes: 102 additions & 2 deletions src/Common/Commands.Common/AzurePSCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public abstract class AzurePSCmdlet : PSCmdlet
protected static AzureProfile _currentProfile = null;
protected static AzurePSDataCollectionProfile _dataCollectionProfile = null;

protected AzurePSQoSEvent QosEvent;

protected virtual bool IsUsageMetricEnabled {
get { return false; }
}

protected virtual bool IsErrorMetricEnabled
{
get { return true; }
}

[Parameter(Mandatory = false, HelpMessage = "In-memory profile.")]
public AzureProfile Profile { get; set; }

Expand Down Expand Up @@ -208,6 +219,22 @@ protected static AzurePSDataCollectionProfile GetDataCollectionProfile()
return _dataCollectionProfile;
}

/// <summary>
/// Check whether the data collection is opted in from user
/// </summary>
/// <returns>true if allowed</returns>
public static bool IsDataCollectionAllowed()
{
if (_dataCollectionProfile != null &&
_dataCollectionProfile.EnableAzureDataCollection.HasValue &&
_dataCollectionProfile.EnableAzureDataCollection.Value)
{
return true;
}

return false;
}

/// <summary>
/// Save the current data collection profile Json data into the default file path
/// </summary>
Expand Down Expand Up @@ -305,7 +332,7 @@ protected override void BeginProcessing()
{
InitializeProfile();
PromptForDataCollectionProfileIfNotExists();

InitializeQosEvent();
if (string.IsNullOrEmpty(ParameterSetName))
{
WriteDebugWithTimestamp(string.Format(Resources.BeginProcessingWithoutParameterSetLog, this.GetType().Name));
Expand Down Expand Up @@ -346,6 +373,7 @@ protected virtual void InitializeProfile()
/// </summary>
protected override void EndProcessing()
{
LogQosEvent();
string message = string.Format(Resources.EndProcessingLog, this.GetType().Name);
WriteDebugWithTimestamp(message);

Expand Down Expand Up @@ -379,6 +407,13 @@ protected bool IsVerbose()
public new void WriteError(ErrorRecord errorRecord)
{
FlushDebugMessages();
if (QosEvent != null && errorRecord != null)
{
QosEvent.Exception = errorRecord.Exception;
QosEvent.IsSuccess = false;
LogQosEvent(true);
}

base.WriteError(errorRecord);
}

Expand Down Expand Up @@ -506,6 +541,62 @@ private void FlushDebugMessages()
}
}

protected void InitializeQosEvent()
{
QosEvent = new AzurePSQoSEvent()
{
CmdletType = this.GetType().Name,
IsSuccess = true,
};

if (this.Profile != null && this.Profile.DefaultSubscription != null)
{
QosEvent.Uid = MetricHelper.GenerateSha256HashString(
this.Profile.DefaultSubscription.Id.ToString());
}
else
{
QosEvent.Uid = "defaultid";
}
}

/// <summary>
/// Invoke this method when the cmdlet is completed or terminated.
/// </summary>
protected void LogQosEvent(bool waitForMetricSending = false)
{
if (QosEvent == null)
{
return;
}

QosEvent.FinishQosEvent();

if (!IsUsageMetricEnabled && (!IsErrorMetricEnabled || QosEvent.IsSuccess))
{
return;
}

if (!IsDataCollectionAllowed())
{
return;
}

WriteDebug(QosEvent.ToString());

try
{
MetricHelper.LogQoSEvent(QosEvent, IsUsageMetricEnabled, IsErrorMetricEnabled);
MetricHelper.FlushMetric(waitForMetricSending);
WriteDebug("Finish sending metric.");
}
catch (Exception e)
{
//Swallow error from Application Insights event collection.
WriteWarning(e.ToString());
}
}

/// <summary>
/// Asks for confirmation before executing the action.
/// </summary>
Expand All @@ -516,10 +607,19 @@ private void FlushDebugMessages()
/// <param name="action">The action code</param>
protected void ConfirmAction(bool force, string actionMessage, string processMessage, string target, Action action)
{
if (QosEvent != null)
{
QosEvent.PauseQoSTimer();
}

if (force || ShouldContinue(actionMessage, ""))
{
if (ShouldProcess(target, processMessage))
{
{
if (QosEvent != null)
{
QosEvent.ResumeQosTimer();
}
action();
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/Common/Commands.Common/Commands.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<CodeAnalysisAdditionalOptions>/assemblyCompareMode:StrongNameIgnoringVersion</CodeAnalysisAdditionalOptions>
<NuGetPackageImportStamp>06e19c11</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -54,6 +55,10 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Hyak.Common.1.0.2\lib\portable-net403+win+wpa81\Hyak.Common.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationInsights, Version=1.1.0.1899, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.ApplicationInsights.1.1.1-beta\lib\net45\Microsoft.ApplicationInsights.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Common">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\packages\Microsoft.Azure.Common.2.1.0\lib\net45\Microsoft.Azure.Common.dll</HintPath>
Expand Down Expand Up @@ -147,6 +152,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="MetricHelper.cs" />
<Compile Include="SecureStringExtensions.cs" />
<Compile Include="ConversionUtilities.cs" />
<Compile Include="DebugStreamTraceListener.cs" />
Expand Down
165 changes: 165 additions & 0 deletions src/Common/Commands.Common/MetricHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Microsoft.ApplicationInsights;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
using Microsoft.WindowsAzure.Commands.Utilities.Common;

namespace Microsoft.WindowsAzure.Commands.Common
{
public static class MetricHelper
{
private const int FlushTimeoutInMilli = 5000;
private static readonly TelemetryClient TelemetryClient;

static MetricHelper()
{
TelemetryClient = new TelemetryClient();
// TODO: InstrumentationKey shall be injected in build server
TelemetryClient.InstrumentationKey = "7df6ff70-8353-4672-80d6-568517fed090";
// Disable IP collection
TelemetryClient.Context.Location.Ip = "0.0.0.0";

if (TestMockSupport.RunningMocked)
{
TelemetryConfiguration.Active.DisableTelemetry = true;
}
}

public static void LogQoSEvent(AzurePSQoSEvent qos, bool isUsageMetricEnabled, bool isErrorMetricEnabled)
{
if (!IsMetricTermAccepted())
{
return;
}

if (isUsageMetricEnabled)
{
LogUsageEvent(qos);
}

if (isErrorMetricEnabled && qos.Exception != null)
{
LogExceptionEvent(qos);
}
}

private static void LogUsageEvent(AzurePSQoSEvent qos)
{
var tcEvent = new RequestTelemetry(qos.CmdletType, qos.StartTime, qos.Duration, string.Empty, qos.IsSuccess);
tcEvent.Context.User.Id = qos.Uid;
tcEvent.Context.User.UserAgent = AzurePowerShell.UserAgentValue.ToString();
tcEvent.Context.Device.OperatingSystem = Environment.OSVersion.VersionString;

TelemetryClient.TrackRequest(tcEvent);
}

private static void LogExceptionEvent(AzurePSQoSEvent qos)
{
//Log as custome event to exclude actual exception message
var tcEvent = new EventTelemetry("CmdletError");
tcEvent.Properties.Add("ExceptionType", qos.Exception.GetType().FullName);
tcEvent.Properties.Add("StackTrace", qos.Exception.StackTrace);
if (qos.Exception.InnerException != null)
{
tcEvent.Properties.Add("InnerExceptionType", qos.Exception.InnerException.GetType().FullName);
tcEvent.Properties.Add("InnerStackTrace", qos.Exception.InnerException.StackTrace);
}

tcEvent.Context.User.Id = qos.Uid;
tcEvent.Properties.Add("CmdletType", qos.CmdletType);

TelemetryClient.TrackEvent(tcEvent);
}

public static bool IsMetricTermAccepted()
{
return AzurePSCmdlet.IsDataCollectionAllowed();
}

public static void FlushMetric(bool waitForMetricSending)
{
if (!IsMetricTermAccepted())
{
return;
}

var flushTask = Task.Run(() => FlushAi());
if (waitForMetricSending)
{
Task.WaitAll(new[] { flushTask }, FlushTimeoutInMilli);
}
}

private static void FlushAi()
{
try
{
TelemetryClient.Flush();
}
catch
{
// ignored
}
}

/// <summary>
/// Gereate a SHA256 Hash string from the originInput.
/// </summary>
/// <param name="originInput"></param>
/// <returns></returns>
public static string GenerateSha256HashString(string originInput)
{
SHA256 sha256 = SHA256.Create();
var bytes = sha256.ComputeHash(Encoding.UTF8.GetBytes(originInput));
return Encoding.UTF8.GetString(bytes);
}
}
}

public class AzurePSQoSEvent
{
private readonly Stopwatch _timer;

public DateTimeOffset StartTime { get; set; }
public TimeSpan Duration { get; set; }
public bool IsSuccess { get; set; }
public string CmdletType { get; set; }
public Exception Exception { get; set; }
public string Uid { get; set; }

public AzurePSQoSEvent()
{
StartTime = DateTimeOffset.Now;
_timer = new Stopwatch();
_timer.Start();
}

public void PauseQoSTimer()
{
_timer.Stop();
}

public void ResumeQosTimer()
{
_timer.Start();
}

public void FinishQosEvent()
{
_timer.Stop();
Duration = _timer.Elapsed;
}

public override string ToString()
{
return string.Format(
"AzureQoSEvent: CmdletType - {0}; IsSuccess - {1}; Duration - {2}; Exception - {3};",
CmdletType, IsSuccess, Duration, Exception);
}
}
1 change: 1 addition & 0 deletions src/Common/Commands.Common/packages.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Hyak.Common" version="1.0.2" targetFramework="net45" />
<package id="Microsoft.ApplicationInsights" version="1.1.1-beta" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net45" />
<package id="Microsoft.Azure.Common.Authentication" version="1.1.3-preview" targetFramework="net45" />
Expand Down
4 changes: 4 additions & 0 deletions src/Common/Commands.ScenarioTest/Commands.ScenarioTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,10 @@
<Project>{58a78f29-8c0c-4a5e-893e-3953c0f29c8a}</Project>
<Name>Commands.ServiceManagement.Test</Name>
</ProjectReference>
<ProjectReference Include="..\..\ServiceManagement\RemoteApp\Commands.RemoteApp\Commands.RemoteApp.csproj">
<Project>{492d2af2-950b-4f2e-8079-8794305313fd}</Project>
<Name>Commands.RemoteApp</Name>
</ProjectReference>
<ProjectReference Include="..\..\ServiceManagement\Services\Commands.Test.Utilities\Commands.Test.Utilities.csproj">
<Project>{bc420543-c04e-4bf3-96e1-cd81b823bdd7}</Project>
<Name>Commands.Test.Utilities</Name>
Expand Down
Loading