-
Notifications
You must be signed in to change notification settings - Fork 38
add support for connecting to Azure Front Door with Azure App Configuration store as an origin #601
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
Open
samsadsam
wants to merge
72
commits into
preview
Choose a base branch
from
user/samisadfa/connect-cdn
base: preview
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 12 commits
Commits
Show all changes
72 commits
Select commit
Hold shift + click to select a range
07d60c1
add connect Cdn
SamSadfa c2fd979
Update src/Microsoft.Extensions.Configuration.AzureAppConfiguration/A…
samsadsam d16a344
make internal
SamSadfa c8b3535
Merge branch 'user/samisadfa/connect-cdn' of https://github.com/Azure…
SamSadfa f3d6b58
Merge branch 'main' into user/samisadfa/connect-cdn
SamSadfa a2e1c5d
add cdn client manager and api version policy
SamSadfa 9b2bcc9
remove unused param
samsadsam bf85303
fix format
samsadsam 7c4fddb
users cannot Connect/ConnectCdn at the same time
samsadsam d323ecd
fix assertion
samsadsam a2ff1b1
feedback
samsadsam 5f16867
add cdn tracing
samsadsam 65b81fc
merge preview
samsadsam 0e2c621
merge with preview
samsadsam 8fc28e8
remove api version policy
samsadsam 2d73ebb
address comment
samsadsam ef09e70
add cdn cache busting policy + accessor for sentinel keys
samsadsam b8ca58e
now refresh with sentinel key works (tested)
samsadsam f1e4bed
move cdn client manager under cdn folder
samsadsam 47a27ea
add comment
samsadsam 491e948
add collection monitoring cdn cache busting support
samsadsam 782dc33
change design to correct one
samsadsam dec256b
bug fix
samsadsam 186288b
another bug fix
samsadsam dbfa697
iterate and implement new design
samsadsam cfc83ce
make code clearer
samsadsam 3631731
nit
samsadsam 2a7f79b
add purpose and simplify hash function
samsadsam d78de74
nit: cleanup and simplification
samsadsam 43a83a0
nit: use nameof on exception message string
samsadsam 7ff8e94
nit: Cdn.ConfigurationClientManager takes one cdn endpoint
samsadsam 73be7e9
nit: _client -> _clientWrapper
samsadsam bd941f0
remove last newline, sort etags before
samsadsam b89f870
rename
samsadsam 4f5108f
handle deleted sentinel kv case
samsadsam 4fc69d3
redesign, no need to ensure state does not regress, eventual consiste…
samsadsam 1d62185
disable load balancing and replica discovery for cdn scenario
samsadsam 6528a36
nit: rename cdn classes accordingly
samsadsam a846f0f
nit: change HaveCollectionChanged to reflect its new role.
samsadsam c95e9ce
nit
samsadsam e1740c9
load balancing is not supported when cdn enabled
samsadsam 29eed77
move load balacing check when cdn is enabled to source
samsadsam 66eccf6
be clearer
samsadsam 326d85b
address avani's comments
samsadsam 984650e
adopt new pattern for tracing features
samsadsam e64307a
bug fix
samsadsam f19cb5d
address jimmy's refactor comment
samsadsam 1803e6b
change implementation
samsadsam 4a54b2e
nit
samsadsam e544048
nit: add new lines
samsadsam ad8c49f
Merge branch 'preview' into user/samisadfa/connect-cdn
samsadsam ad5ac9b
add refresh under cdn testing and fix bug
samsadsam 33a9fb5
make tests more robust
samsadsam de1dc29
Merge branch 'user/samisadfa/connect-cdn' of https://github.com/Azure…
samsadsam 1abb191
nit
samsadsam 911f815
nits
samsadsam 568a7e8
ensure test is inductive
samsadsam 4880269
handle ConnectCdn with SetClientFactory scenario
samsadsam 23acfff
nit: add ms license
samsadsam bd487dc
move all cdn related tests to cdn tests
samsadsam 2c2a413
add parallel test
samsadsam d8f280a
fix bug
samsadsam ae0e448
tests: add delete sentinel key to test
samsadsam feaec53
done
samsadsam 3f71dd4
done1
samsadsam c1d15aa
done2
samsadsam 0292b78
Update src/Microsoft.Extensions.Configuration.AzureAppConfiguration/A…
samsadsam be6d888
done3
samsadsam cfb5cf6
Merge branch 'user/samisadfa/connect-cdn' of https://github.com/Azure…
samsadsam eef8180
donedone
samsadsam cae49ce
donedonedone
samsadsam 39ddcae
remove auth header when connecting to cdn
samsadsam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/Microsoft.Extensions.Configuration.AzureAppConfiguration/CdnApiVersionPolicy.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT license. | ||
// | ||
using Azure.Core; | ||
using Azure.Core.Pipeline; | ||
using System; | ||
using System.Collections.Specialized; | ||
using System.Threading.Tasks; | ||
using System.Web; | ||
|
||
namespace Microsoft.Extensions.Configuration.AzureAppConfiguration | ||
{ | ||
/// <summary> | ||
/// A policy that adds the API version query parameter to HTTP requests. | ||
/// </summary> | ||
public class CdnApiVersionPolicy : HttpPipelinePolicy | ||
{ | ||
/// <summary> | ||
/// Processes the HTTP message by adding the API version query parameter. | ||
/// </summary> | ||
/// <param name="message">The HTTP message to process.</param> | ||
/// <param name="pipeline">The pipeline of HTTP policies to apply.</param> | ||
public override void Process(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline) | ||
{ | ||
message.Request.Uri.Reset(AlterApiVersion(message.Request.Uri.ToUri())); | ||
|
||
ProcessNext(message, pipeline); | ||
} | ||
|
||
/// <summary> | ||
/// Processes the HTTP message asynchronously by adding the API version query parameter. | ||
/// </summary> | ||
/// <param name="message">The HTTP message to process.</param> | ||
/// <param name="pipeline">The pipeline of HTTP policies to apply.</param> | ||
/// <returns>A ValueTask representing the asynchronous operation.</returns> | ||
public override async ValueTask ProcessAsync(HttpMessage message, ReadOnlyMemory<HttpPipelinePolicy> pipeline) | ||
{ | ||
message.Request.Uri.Reset(AlterApiVersion(message.Request.Uri.ToUri())); | ||
|
||
await ProcessNextAsync(message, pipeline).ConfigureAwait(false); | ||
} | ||
|
||
private static Uri AlterApiVersion(Uri uri) | ||
{ | ||
var uriBuilder = new UriBuilder(uri); | ||
|
||
NameValueCollection query = HttpUtility.ParseQueryString(uriBuilder.Query); | ||
query["api-version"] = "2024-09-01-preview"; | ||
|
||
uriBuilder.Query = query.ToString(); | ||
|
||
return uriBuilder.Uri; | ||
} | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...Microsoft.Extensions.Configuration.AzureAppConfiguration/CdnConfigurationClientManager.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using Azure.Data.AppConfiguration; | ||
samsadsam marked this conversation as resolved.
Show resolved
Hide resolved
|
||
using Microsoft.Extensions.Azure; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
namespace Microsoft.Extensions.Configuration.AzureAppConfiguration | ||
{ | ||
internal class CdnConfigurationClientManager : IConfigurationClientManager | ||
{ | ||
private readonly IList<ConfigurationClientWrapper> _clients; | ||
|
||
public CdnConfigurationClientManager( | ||
IAzureClientFactory<ConfigurationClient> clientFactory, | ||
IEnumerable<Uri> endpoints) | ||
{ | ||
if (clientFactory == null) | ||
{ | ||
throw new ArgumentNullException(nameof(clientFactory)); | ||
} | ||
|
||
_clients = endpoints | ||
.Select(endpoint => new ConfigurationClientWrapper(endpoint, clientFactory.CreateClient(endpoint.AbsoluteUri))) | ||
.ToList(); | ||
} | ||
|
||
public IEnumerable<ConfigurationClient> GetClients() | ||
{ | ||
return _clients.Select(c => c.Client); | ||
} | ||
|
||
public void RefreshClients() | ||
{ | ||
return; | ||
} | ||
|
||
public bool UpdateSyncToken(Uri endpoint, string syncToken) | ||
{ | ||
if (endpoint == null) | ||
{ | ||
throw new ArgumentNullException(nameof(endpoint)); | ||
} | ||
|
||
if (string.IsNullOrWhiteSpace(syncToken)) | ||
{ | ||
throw new ArgumentNullException(nameof(syncToken)); | ||
} | ||
|
||
ConfigurationClientWrapper clientWrapper = _clients.SingleOrDefault(c => new EndpointComparer().Equals(c.Endpoint, endpoint)); | ||
|
||
if (clientWrapper != null) | ||
{ | ||
clientWrapper.Client.UpdateSyncToken(syncToken); | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public Uri GetEndpointForClient(ConfigurationClient client) | ||
{ | ||
if (client == null) | ||
{ | ||
throw new ArgumentNullException(nameof(client)); | ||
} | ||
|
||
ConfigurationClientWrapper currentClient = _clients.FirstOrDefault(c => c.Client == client); | ||
|
||
return currentClient?.Endpoint; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Microsoft.Extensions.Configuration.AzureAppConfiguration/EmptyTokenCredential.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Azure.Core; | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Microsoft.Extensions.Configuration.AzureAppConfiguration | ||
{ | ||
/// <summary> | ||
/// A token credential that provides an empty token. | ||
/// </summary> | ||
internal class EmptyTokenCredential : TokenCredential | ||
{ | ||
/// <summary> | ||
/// Gets an empty token. | ||
/// </summary> | ||
/// <param name="requestContext">The context of the token request.</param> | ||
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param> | ||
/// <returns>An empty access token.</returns> | ||
public override AccessToken GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken) | ||
{ | ||
return new AccessToken(string.Empty, DateTimeOffset.MaxValue); | ||
} | ||
|
||
/// <summary> | ||
/// Asynchronously gets an empty token. | ||
/// </summary> | ||
/// <param name="requestContext">The context of the token request.</param> | ||
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param> | ||
/// <returns>A task that represents the asynchronous operation. The task result contains an empty access token.</returns> | ||
public override ValueTask<AccessToken> GetTokenAsync(TokenRequestContext requestContext, CancellationToken cancellationToken) | ||
{ | ||
return new ValueTask<AccessToken>(new AccessToken(string.Empty, DateTimeOffset.MaxValue)); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.