Skip to content
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

Load From CDN #123

Open
wants to merge 45 commits into
base: release/v2
Choose a base branch
from

Conversation

zhiyuanliang-ms
Copy link
Contributor

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

Why this PR?

App Config supports SAS token authentication which targets on the CDN scenario. This PR adds a new API loadFromCdn which allows user to load key values from the CDN. Note the CDN can be considered as a proxy and cache for the App Config. The CDN will forward the request to App Config and use SAS token for authentication.

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

Visible changes

Only the latest preview version of App Config service supports the sas token authentication which the CDN will use.
The latest js sdk allows use to specify the api version manually. ref Updated the dependency of sdk to 1.8.0.

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:

Startup

key=Test1*          - Page1_Etag
key=Test1*&after=token1    - Page2_Etag
key=Test1*&after=token2    - Page3_Etag

key=Test2*          - P1_Etag
key=Test2*&after=t1      - P2_Etag
key=Test2*&after=t2      - P3_Etag


Refresh (No server change)

key=Test1*&_=Page1_Etag        - Page1_Etag
key=Test1*&after=token1&_=Page1_Etag  - Page2_Etag
key=Test1*&after=token2&_=Page1_Etag  - Page3_Etag

key=Test2*&_=Page1_Etag        - P1_Etag
key=Test2*&after=t1&_=Page1_Etag    - P2_Etag
key=Test2*&after=t2&_=Page1_Etag    - P3_Etag


Refresh (Server change observed after CDN cache expired)

key=Test1*&_=Page1_Etag        - Page1_Etag
key=Test1*&after=token1&_=Page1_Etag  - Page2_Etag_New

Break and reload all with changed page etag

key=Test1*&_=Page2_Etag_New        - Page1_Etag
key=Test1*&after=token1&_=Page2_Etag_New  - Page2_Etag_New
key=Test1*&after=token2&_=Page2_Etag_New  - Page3_Etag_New

key=Test2*&_=Page2_Etag_New        - P1_Etag
key=Test2*&after=t1&_=Page2_Etag_New    - P2_Etag
key=Test2*&after=t2&_=Page2_Etag_New    - P3_Etag

@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.

src/load.ts Outdated Show resolved Hide resolved
@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
@zhiyuanliang-ms
Copy link
Contributor Author

Changed the target branch to the key value collection monitoring PR's branch #133 , as it will be the recommended way of dynamic refresh for CDN scenario.

@rossgrambo rossgrambo self-requested a review December 5, 2024 17:38
@rossgrambo
Copy link
Member

This is blocked for now pending some CDN decisions

Base automatically changed from zhiyuanliang/register-all-refresh to preview December 19, 2024 05:51

Choose a reason for hiding this comment

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

Copilot reviewed 6 out of 12 changed files in this pull request and generated no comments.

Files not reviewed (6)
  • package.json: Language not supported
  • test/utils/testHelper.ts: Evaluated as low risk
  • src/index.ts: Evaluated as low risk
  • test/exportedApi.ts: Evaluated as low risk
  • test/loadBalance.test.ts: Evaluated as low risk
  • src/requestTracing/constants.ts: Evaluated as low risk
Comments suppressed due to low confidence (7)

src/load.ts:50

  • [nitpick] The variable name credentialOrOptions is ambiguous. It should be renamed to credentialOrOptionsOrEmptyTokenCredential.
const appConfiguration = new AzureAppConfigurationImpl(clientManager, options, credentialOrOptions === emptyTokenCredential);

src/AzureAppConfigurationImpl.ts:55

  • [nitpick] Consider renaming the property 'etagToBreakCdnCache' to 'cacheBreakEtag' for better readability and consistency.
etagToBreakCdnCache?: string;

src/AzureAppConfigurationImpl.ts:261

  • [nitpick] Consider renaming the property 'etagToBreakCdnCache' to 'cacheBreakEtag' for better readability and consistency.
this.#kvSelectorCollection.etagToBreakCdnCache = this.#sentinels.find(s => s.etag !== undefined)?.etag;

src/AzureAppConfigurationImpl.ts:543

  • [nitpick] Consider renaming the property 'etagToBreakCdnCache' to 'cacheBreakEtag' for better readability and consistency.
this.#kvSelectorCollection.etagToBreakCdnCache = sentinel.etag;

src/AzureAppConfigurationImpl.ts:606

  • [nitpick] Consider renaming the property 'etagToBreakCdnCache' to 'cacheBreakEtag' for better readability and consistency.
selectorCollection.etagToBreakCdnCache = undefined;

src/AzureAppConfigurationImpl.ts:615

  • [nitpick] Consider renaming the property 'etagToBreakCdnCache' to 'cacheBreakEtag' for better readability and consistency.
selectorCollection.etagToBreakCdnCache = page.etag;

src/AzureAppConfigurationImpl.ts:623

  • [nitpick] Consider renaming the property 'etagToBreakCdnCache' to 'cacheBreakEtag' for better readability and consistency.
selectorCollection.etagToBreakCdnCache = selector.pageEtags[i];
Base automatically changed from preview to release/v2 January 7, 2025 09:43
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