Skip to content
Merged
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
28 changes: 17 additions & 11 deletions src/ResourceManager/Version2016_09_01/AzureRMCmdlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,22 @@ public virtual bool TryGetDefaultContext(out IAzureContext context)
return result;
}

protected override void EndProcessing()
{
IAzureContext context;
_qosEvent.Uid = "defaultid";
if (TryGetDefaultContext(out context) && context != null)
{
_qosEvent.SubscriptionId = context.Subscription?.Id;
_qosEvent.TenantId = context.Tenant?.Id;
if (context.Account != null && !String.IsNullOrWhiteSpace(context.Account.Id))
{
_qosEvent.Uid = MetricHelper.GenerateSha256HashString(context.Account.Id.ToString());
}
}
base.EndProcessing();
}

/// <summary>
/// Gets the current default context.
/// </summary>
Expand Down Expand Up @@ -380,17 +396,7 @@ protected override void InitializeQosEvent()
{
base.InitializeQosEvent();

IAzureContext context;
_qosEvent.Uid = "defaultid";
if (RequireDefaultContext() && TryGetDefaultContext(out context))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need more time to check if it's safe to remove RequireDefaultContext. Will catch up next week

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@YanaXu can you test running some cmdlets that doesn't require a context after clearing the context? They should still work without a context.
Examples are the *DataCollection and ContextAutoSave cmdlets.

{
_qosEvent.SubscriptionId = context.Subscription?.Id;
_qosEvent.TenantId = context.Tenant?.Id;
if (context.Account != null && !String.IsNullOrWhiteSpace(context.Account.Id))
{
_qosEvent.Uid = MetricHelper.GenerateSha256HashString(context.Account.Id.ToString());
}
}

}

protected override void LogCmdletStartInvocationInfo()
Expand Down