-
Notifications
You must be signed in to change notification settings - Fork 295
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
[POC] AAD: Configuring ServerTelemetryChannel and QuickPulseServiceClient #2220
Conversation
change reflection to use a compiled expression.
…annels and QuickPulseModule. Need to write tests.
|
||
if (aadToken == null) | ||
{ | ||
// TODO: DO NOT SEND. RETURN FAILURE AND LET CHANNEL DECIDE WHEN TO RETRY. |
There was a problem hiding this comment.
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..
@@ -381,6 +386,12 @@ private void AddHeaders(HttpWebRequest request, bool includeIdentityHeaders, str | |||
request.Headers.Add(QuickPulseConstants.XMsQpsInvariantVersionHeaderName, | |||
MonitoringDataPoint.CurrentInvariantVersion.ToString(CultureInfo.InvariantCulture)); | |||
} | |||
|
|||
// The AAD token is an optional feature. Only include if it is provided. | |||
if (!string.IsNullOrEmpty(aadToken)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
@@ -96,6 +95,20 @@ public TimeSpan SendingInterval | |||
} | |||
} | |||
|
|||
/// <summary> | |||
/// Gets or sets the <see cref="CredentialEnvelope"/> which is used for AAD. | |||
/// FOR INTERNAL USE. Customers should use <see cref="TelemetryConfiguration.SetAzureTokenCredential"/> instead. |
There was a problem hiding this comment.
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.
@@ -107,6 +108,15 @@ public virtual int ThrottleWindow | |||
} | |||
} | |||
|
|||
/// <summary> | |||
/// Gets or sets the <see cref="CredentialEnvelope"/> which is used for AAD. |
There was a problem hiding this comment.
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".
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 methodSetAzureTokenCredential
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 eitherInMemoryChannel
orServerTelemetryChannel
.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 aTransmission
needs to be retried, it will receive a new token.InMemoryChannel
InMemoryChannel.CredentialEnvelope
setsInMemoryTransmitter.CredentialEnvelope
which is used to setTransmission.CredentialEnvelope
just before callingTransmission.SendAsync
.ServerTelemetryChannel
ServerTelemetryChannel.CredentialEnvelope
setsTransmitter.CredentialEnvelope
and then setsTransmissionSender.CredentialEnvelope
which is used to setTransmission.CredentialEnvelope
just before callingTransmission.SendAsync
.