Skip to content

[POC] AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient#2220

Closed
TimothyMothra wants to merge 116 commits intodevelopfrom
tilee/feature_aad_w_config
Closed

[POC] AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient#2220
TimothyMothra wants to merge 116 commits intodevelopfrom
tilee/feature_aad_w_config

Conversation

@TimothyMothra
Copy link
Copy Markdown

@TimothyMothra TimothyMothra commented Apr 9, 2021

Consuming CredentialEnvelope within TelemetryChannels and QuickPulseServiceClient

For more information see the parent item: #2190.

Introduction

This PR demonstrates an approach to handling the configuration of the CredentialEnvelope.

TODO: Need to write unit tests to validate possible configuration scenarios.

TelemetryConfiguration

TelemetryConfiguration has a method SetAzureTokenCredential for a user to provide the TokenCredential.
This method could be called either before or after the user has set the TelemetryChannel.

To deal with this, both setting a credential and setting a TelemetryChannel will invoke TelemetryConfiguration.SetTelemetryChannelCredentialEnvelope.

ISupportCredentialEnvelope

To simplify passing the CredentialEnvelope to the TelemetryChannels, I've introduced a new interface ISupportCredentialEnvelope.
This ensures that the TelemetryConfiguration can set either InMemoryChannel or ServerTelemetryChannel.

TelemetryChannels

Each TelemetryChannel must provide the CredentialEnvelope on their respective internal classes.
TelemetryItems ultimately end up stored in a Transmission object. This object can be serialized for file storage. I've confirmed that the Credential object will not be serialized.

Tokens themselves will expire and therefore are not set on the Transmission object until just before invoking Transmission.SendAsync. If a Transmission needs to be retried, it will receive a new token.

InMemoryChannel

InMemoryChannel.CredentialEnvelope sets InMemoryTransmitter.CredentialEnvelope which is used to set Transmission.CredentialEnvelope just before calling Transmission.SendAsync.

ServerTelemetryChannel

ServerTelemetryChannel.CredentialEnvelope sets Transmitter.CredentialEnvelope and then sets TransmissionSender.CredentialEnvelope which is used to set Transmission.CredentialEnvelope just before calling Transmission.SendAsync.


if (aadToken == null)
{
// TODO: DO NOT SEND. RETURN FAILURE AND LET CHANNEL DECIDE WHEN TO RETRY.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this will be considered a client side failure, and data would not be retried by default.
Its probably a complex part to decide if we want to store items for later retry, if the AAD is down..

}

// The AAD token is an optional feature. Only include if it is provided.
if (!string.IsNullOrEmpty(aadToken))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is this intentionally optional for QP? elsewhere, in the regular channel, its like mandatory, if user has set tc.settokencred.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

oh good catch. i need to rethink this

@TimothyMothra TimothyMothra mentioned this pull request May 28, 2021
4 tasks
@TimothyMothra TimothyMothra changed the title AAD: Configuring TelemetryChannels and QuickPulse AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient May 29, 2021
@TimothyMothra TimothyMothra changed the title AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient [POC] AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient May 29, 2021
This was referenced May 29, 2021

/// <summary>
/// Gets or sets the <see cref="CredentialEnvelope"/> which is used for AAD.
/// FOR INTERNAL USE. Customers should use <see cref="TelemetryConfiguration.SetAzureTokenCredential"/> instead.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We don't really need this comment anymore since ISupportCredentialEnvelope is, itself, internal.

}

/// <summary>
/// Gets or sets the <see cref="CredentialEnvelope"/> which is used for AAD.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of "AAD", suggest "authorization" or "auth-token acquisition".

@TimothyMothra TimothyMothra deleted the tilee/feature_aad_w_config branch June 3, 2021 18:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants