Skip to content

Load From Azure Front Door #123

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
wants to merge 72 commits into
base: preview
Choose a base branch
from

Conversation

zhiyuanliang-ms
Copy link
Contributor

@zhiyuanliang-ms zhiyuanliang-ms commented Nov 4, 2024

Why this PR?

This feature is targeted on the CDN story.

This PR adds a new API loadFromAzureFrontDoor which allows user to load key values from the Azure Front Door. The Azure Front Door will forward the request to App Config and use managed identity for authentication.

For CDN scenario, the recommended way for dynamic refresh is "watch all". We introduced key value collection monitoring based refresh in #133 .

The implementation is aligned with #601

Visible changes

No conditional request will be sent when CDN is used.

To break cdn cache, we will use a pipeline policy to append query param _=<last-changed-etag> to all the request sending to cdn.

Example:

Initial load - no etag

First watch request - no etag

Change detected:

1. sentinel key change 

All the following refresh/watch request (until new change detected) - sentinel key etag

2. sentinel key deleted

All the following refresh/watchrequest (until new change detected) - SHA256(ResourceDeleted\nprevious sentinel key etag) (Use hash to hide the "ResourceDeleted")

3. page etag change

All the following refresh/watch request (until new change detected) - the first changed page etag

We send different requests to retrieve feature flag and key values

@zhiyuanliang-ms zhiyuanliang-ms changed the title Use the correct api version when load from cdn Load From CDN Nov 5, 2024
@zhiyuanliang-ms
Copy link
Contributor Author

zhiyuanliang-ms commented Nov 5, 2024

I reverted the original commit of adding loadFromCdn (#130) to unblock doing release for EXP telemetry changes.
We still have the issue with supporting dynamic refresh for CDN scenario:

  1. You are not guaranteed to get the latest etag of sentinal key because cdn's cache may not expired. During refresh we should force cdn to pull the latest etag.

This PR will contains all changes of the complete solution of loading from cdn.

@zhiyuanliang-ms zhiyuanliang-ms force-pushed the zhiyuanliang/enforce-api-version-for-cdn branch from 1eaa43e to 62ac2b9 Compare November 10, 2024 17:34
@zhiyuanliang-ms zhiyuanliang-ms changed the base branch from preview to zhiyuanliang/register-all-refresh November 19, 2024 08:02
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a new API (loadFromCdn) to support loading configuration key-values from a CDN while breaking the CDN cache by appending a query parameter based on etag changes. It also refactors internal selector management in AzureAppConfigurationImpl and adjusts related tests and exports to support the CDN scenario.

  • Adds loadFromCdn API and its supporting pipeline policy and tests.
  • Refactors selector collections in AzureAppConfigurationImpl to handle CDN-specific logic.
  • Updates test helpers and exports to integrate and validate CDN behavior.

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/utils/testHelper.ts Updates function signature for load balance mode to pass pages instead of emptyPages.
test/requestTracing.test.ts Adds tests to verify the CDN tag in the correlation-context header.
test/loadBalance.test.ts Modifies load balance tests to use the updated API with mocked key-value pages.
test/exportedApi.ts Re-exports the new loadFromCdn API.
src/requestTracing/utils.ts Incorporates the new isCdnUsed flag and CDN tag into request tracing header creation.
src/load.ts Implements the loadFromCdn API and introduces an emptyTokenCredential for CDN requests.
src/index.ts Updates exported APIs to include loadFromCdn.
src/common/utils.ts Adds getCryptoModule for cross-environment crypto support.
src/EtagUrlPipelinePolicy.ts Creates a policy to append an etag query parameter for breaking the CDN cache.
src/AzureAppConfigurationImpl.ts Refactors selector management and integrates CDN handling into configuration loading.
package.json Bumps @azure/app-configuration dependency version.
Comments suppressed due to low confidence (2)

src/AzureAppConfigurationImpl.ts:771

  • [nitpick] Consider renaming the loop variable 'i' to 'pageIndex' or another more descriptive name to improve code readability.
let i = 0;

src/load.ts:52

  • [nitpick] Update the function documentation to clearly explain the purpose of the additional boolean flag (indicating if the empty token credential was used) when calling AzureAppConfigurationImpl.
const appConfiguration = new AzureAppConfigurationImpl(clientManager, options, credentialOrOptions === emptyTokenCredential);

@zhiyuanliang-ms zhiyuanliang-ms force-pushed the zhiyuanliang/enforce-api-version-for-cdn branch from 4a2eebd to a30b421 Compare June 6, 2025 02:07
@zhiyuanliang-ms zhiyuanliang-ms changed the title Load From CDN Load From Azure Front Door Jun 12, 2025
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.

5 participants