Skip to content

Commit a3fed9a

Browse files
zhiyuanliang-msamerjusupovicrossgramboSamSadfasamsadsam
authored
Merge preview to release/preview/v8 (#709)
* Use TryAddSingleton instead of AddSingleton for extension (#643) * use TryAddSingleton instead of AddSingleton in extension, fix refresherprovider accordingly * remove unused using * add comment * Fix format (#647) * fix format * fix format * fix format * fix format * Add request tracing for content type (#646) * add initial content type pattern * format fix * fix comment * update to account for chat completion vs ai profiles * in progress fix adapter to use existing requesttracingoptions * use content type tracing to pass to requesttracingoptions * fix comments and naming * remove unneeded file * add check for request tracing enabled * check content type in preparedata * remove errors * fix spacing * fix test * remove unused usings, add back catch for .net framework * fix parsing * rename constants * fix indent * update for PR comments * PR comments, update if conditions * add isjson check * update isjson extension * Fix test to use new refresh interval api (#650) * fix test to remove obsolete * change variable names * Separate content type exclusion logic from IsJson extension (#651) * fix isjson and separate exclusion logic * update adapters to use new extension * PR comments * update package versions to 8.1.2 (#648) * Revert "Shorten the defeult timeout of individual call to backend (#620)" (#653) This reverts commit 87f0f85. * Add activity source to allow OpenTelemetry to collect tracing (#645) * add activity source * add minimum requirement for MinBackOffDuration * Revert "add minimum requirement for MinBackOffDuration" This reverts commit 59d847a. * revert make MinBackoffDuration public * update * update activity name * update * Removed FeatureFlagId * Add support for filtering by tags (#637) * Adding allocation id * serialize with sorted keys * use string empty * nit * rename ff id to TelemetryVariantPercentile * add more values * dotnet format * Version bump * Add `RegisterAll` API to enable monitoring collections of key-values for refresh (#574) * WIP * WIP testing out client extensions methods * WIP added selectors to multikeywatchers * remove unused property * WIP check for registerall changes to change refreshall * WIP * WIP fixing types and reslving errors * WIP fixing client extensions class * WIP * WIP update feature flag logic * WIP client extensions * WIP reload all flags on change * WIP * WIP fixing tests to return response for getconfigurationsettingsasync * WIP etag for tests * fix watchedcollections null * WIP tests, working for examples * remove unused variables * update to newest sdk version, remove unused * WIP fixing tests * WIP reworking testing to work with new etag approach * tests passing, fix mockasyncpageable * update sdk package version * fix loghelper, tests * WIP fixing aspages tests * revert watchesfeatureflags test * update test again * WIP * fixing watchconditions * separate selected key value collections from feature flag collections, separate selectors, add new methods to support new logic * comment and naming updates * fixing unit tests, namespace of defining/calling code needs to be same * fixing tests using AsPages * fix tests with pageablemanager * format * fix tests * fix tests * remove unused extension test class * fix comment, capitalization * check etag on 200, fix tests * add registerall test, fix refresh tests * fix condition for pages and old match conditions * WIP fixing PR comments, tests * check status after advancing existing etag enumerator * move around refresh logic * null check page etag, revert break to existing keys check in getrefreshedcollections * fix loadselected, replace selectedkvwatchers with registerall refresh time * fix comment in options * clean up tests * PR comments * PR comments * don't allow both registerall and register * fix check for calls to both register methods * PR comments for rename/small changes * fix compile error * simplify refreshasync path, fix naming from comments * remove redundant if check * simplify logic for minrefreshinterval * fix smaller comments * call loadselected when refreshing collection, separate data for individual refresh * in progress change to registerall include ff * fix load order * fix comments, rename logging constants to match new behavior * pr comments, refactor refreshasync * clean up etags dictionary creation * PR comments * add uncommitted changes to testhelper * update tests for registerall with feature flags, check ff keys to remove flags on refresh * PR comments * PR comments * use invalidoperationexception in configurerefresh, update loggingconstants to match behavior * remove unused changes * Give the users the ability to have control over ConfigurationClient instance(s) used by the provider (#598) (#617) * Introduced a new `AzureAppConfigurationClientFactory` class to handle the creation of `ConfigurationClient` instances * remove clients dictionary since we will not have hits and clients are already stored in ConfigurationClientManager * revert * add license + remove unused usings * ran dotnet format * add capability of fallback to different stores * add explicit type * address comments * remove scheme validation --------- Co-authored-by: Sami Sadfa <[email protected]> Co-authored-by: Sami Sadfa <[email protected]> * first draft tag filtering support * add alternate APIs * change to use ienumerable * update featureflagoptions to match main options * update keyvalueselector equals and hashcode * update param comments for selects * fix merge conflict errors * add validation for tagsfilter param, add to comment * edit error message for format * edit comment * add unit tests * remove unused file * revert versions * update tests to include feature flag select * add refresh test * ff only refresh test * update equals for selector * fix equals * update equals * reorder properties in keyvalueselector * upgrade to 8.2.0-preview (#638) * fix incorrect test * fix equals for selector * update gethashcode for keyvalueselector * PR comments, in progress * update tests from PR comments * add validation for number of tags, add test * rename tagsFilter to tagsFilters everywhere * fix usings, missing updates to ffoptions * update ffoptions select again * fix tests * update sdk version * update tagsfilters to tagfilters * remove tagsfilters again * PR comments * PR comments * Revert "Merge pull request #600 from Azure/rossgrambo/allocation_id" This reverts commit 51d4ad7, reversing changes made to d551536. * Revert "Give the users the ability to have control over ConfigurationClient instance(s) used by the provider (#598) (#617)" This reverts commit 6dc9ae2. --------- Co-authored-by: Ross Grambo <[email protected]> Co-authored-by: Sami Sadfa <[email protected]> Co-authored-by: Sami Sadfa <[email protected]> Co-authored-by: Sami Sadfa <[email protected]> * Clarify client factory comment (#660) * add comment to setclientfactory * update comment * update comment * Shorten default timeout of individual calls to backend (#657) * in progress fix shorten timeout PR * dispose httpclienttransport * remove unnecessary check * fix disposal pattern * fix static compile error * remove unused using * reset options * fix options * add line to options * use retryoptions.networktimeout * add test, update isfailoverable * update test comment * update test * remove check for nested taskcanceledexception * simplify if statement in isfailoverable * renormalize options * update package versions to 8.2.0 (#662) * Add .gitattributes and normalize line endings (#661) * add gitattributes and renormalize any files * newline end of file * file start with mit license * fix typo * update to 2023-11-01 (#663) * Add integration testing (#634) * add initial integration test file * update auth * add skipping * organize tests into unit and integration * update formatting * WIP create config store * edit * update integration setup * copilot updates * initial working version of integration tests * remove obsolete tags and update formatting * updating tests * format * remove skipping, add tests * add cleanup stale resource call on startup and dispose * add back removed line * use persistent resource group * add ordering of apis test * add refresh test * add tests * add failover test * adding snapshot tests first draft * fix snapshot tests * add key vault tests * add more keyvault tests * fix keyvault tests * add cleanup of key values/secrets/snapshot * fix key vault isolation * remove base exception catches * update ci.yml to work with integration tests and use github repo secrets * add id token write permission * update ci.yml step to create subscription file * edit ci.yml * fix github action * update comment in powershell script * remove unused packages * update comment, remove unused methods * add request tracing test * check for status code in catch, move cleanupstaleresources call to dispose * PR comments * comments * comments * update copilot instructions * update copilot instructions * fix try blocks to only surround throwing code * fix setuptestkeys, simplify comments and setup code * tagfilters integration test in progress * tagfilters integration test in progress * correct api version * fixed tagfilter test * fix requesttracing test * allow commas in json reader * stale threshold * remove copilot instructions * use outputhelper * fix cleanupstale * update setup method, remove flag * Support health check (#644) * support health check * update * reord last successful time in ExecuteWithFailoverPolicy * make health check compatible with DI * add health check for each provider instance * update * update comment * Undo package version change * Add Copilot instructions (#667) * add copilot instructions * fix grammar * Update .github/code-gen-instructions.md Co-authored-by: Jimmy Campbell <[email protected]> --------- Co-authored-by: Jimmy Campbell <[email protected]> * Add CodeQL exclusions for code samples * Fix ConfigStoreDemo sample for CodeQL alerts (#677) * initial fixes to jquery for codeql alerts * add other wwwroot files * remove comment * redo line endings on configstoredemo sample files * update site css to fit title * fix title spacing * update to aspnet ajax instead * Add testcase for refresh activity (#665) * add testcase for refresh activity * update * update * update * Add environment variable to disable feature management schema compatibility logic (#676) * add environment variable, unit test * remove comments * Update src/Microsoft.Extensions.Configuration.AzureAppConfiguration/FeatureManagement/FeatureManagementKeyValueAdapter.cs Co-authored-by: Copilot <[email protected]> * fix unit test * update comments * move bool parsing logic outside try * fix formatting * add environment variable class * update * update --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: Zhiyuan Liang <[email protected]> Co-authored-by: Zhiyuan Liang <[email protected]> * version bump 8.3.0 (#682) * Merge pull request #684 from Azure/zhiyuanliang/fix-test Fix activity source test bug * Fix bug with endpoint failover (#686) * update endpoint in do while * add test * in progress * update test, update logic to backoff using correct endpoint * make test more specific --------- Co-authored-by: AMER JUSUPOVIC <[email protected]> Co-authored-by: Amer Jusupovic <[email protected]> * Support comment in json key value (#685) * support jsonc * remove unused reference * use private static option * Add request tracing for Aspire usage (#687) * add request tracing for aspire component * update tag name * version bump 8.4.0 (#690) * Adding Snapshot References Feature (#689) * feat: defined snapshot reference content type and Json Property * added snapshot reference content type to content type extensions * updated the snapshot reference content type to include the charset * Implementing snapshot references * Fixed the behavior of an edge case and moved file to a better location in repo * created unit tests for Snapshot References * Removed unnecessary comments from tests * removed extra comments and cleaned up code * modified test and added set up for testing snapshot references * adding more integration tests for snapshot references * removed client and cancellation token from snapshot reference class and updated all affected code * updated namespaces for all files and created parser class * additional file to update namespace * Modified the code to directly use the content type instead of copying * Used object initializer pattern and passed in cancellationTokens to async methods * fixed comment and updated TestContext format * updated behavior to throw exception if snapshot name is null * Moved the exception error messages from inline to ErrorMessages class and renamed parsing method to Parse() * Added Request tracing and case for snapshot reference is registered for refresh by not called in select * added test case to test adding snapshot reference to register but not part of select * updating request tracing to only tracking use of snapshot references * removing request tracing logic for Snapshot References count * added comments and returning SnapshotReference type from Parse() * removed second way of checking for snapshot references type and updated test cases * removed redundant error message * removed unnecessary code * fixed whitespace issues and made error message clearer * updating naming and removing old telemetry code * updated namespace and directory to SnapshotReference * Added new JsonFields type * fixed error regarding same namespace and type * Updated the Parse logic to handle all exceptions instead of LoadSnapshotData * updated comments to method * removed the update and reset snapshot reference request tracing methods as they were unnecessary * removed requestTracing for SnapshotReference from refresh * reverting previous change * Made these keyvault integration tests more resilient * Cleaning up code * More nit changes * updated request tracing for snapshot references in refresh * making the key vault integration test more resilient * correction to which test needed resilience * Merge pull request #695 from Azure/zhiyuanliang/upgrade-dependency Drop .net 6 & Upgrade dependency * Fix integration test bug (#697) * delete kv sequentially * fix snapshot creation and deletion bug * fix * update retention period * Add AddAzureAppConfiguration overload to take endpoint and entra id (#694) * add overload to take endpoint and credential * enrich comment for intellisense * update comment to point to use options.connect pattern * update * Merge pull request #700 from Azure/zhiyuanliang/dummy-health-check Add AlwaysHealthy health check when provider is disabled * Support Azure Front Door (#706) * wip * wip * wip * wip * fix test * wip * wip * wip * add test * update correlation context * update * only check response time for refresh trigger engine * disallow sentinel key refresh for AFD * add feature flag refresh test * update * resolve comments * update * update error message * upgrade sdk version * update test * version bump 8.5.0-preview (#708) --------- Co-authored-by: Amer Jusupovic <[email protected]> Co-authored-by: Ross Grambo <[email protected]> Co-authored-by: AMER JUSUPOVIC <[email protected]> Co-authored-by: Sami Sadfa <[email protected]> Co-authored-by: Sami Sadfa <[email protected]> Co-authored-by: Sami Sadfa <[email protected]> Co-authored-by: Jimmy Campbell <[email protected]> Co-authored-by: Richard Muniu <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: t-vvidyasaga <[email protected]>
2 parents 8d1e942 + 80a9f30 commit a3fed9a

File tree

381 files changed

+95105
-15480
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

381 files changed

+95105
-15480
lines changed

.gitattributes

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# If there are abnormal line endings in any file, run "git add --renormalize <file_name>",
2+
# review the changes, and commit them to fix the line endings.
3+
* text=auto
4+
5+
# Third-party library files should not have line endings normalized
6+
**/wwwroot/lib/** -text
7+
*.min.css -text
8+
*.min.js -text
9+
*.map -text

.github/code-gen-instructions.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# AppConfiguration-DotnetProvider Coding Guidelines
2+
3+
This document outlines coding guidelines for the Azure App Configuration .NET Provider repository. Follow these guidelines when generating or modifying code.
4+
5+
## General Guidelines
6+
7+
1. **Exception Handling**:
8+
* When adding error handling, always catch specific exceptions and avoid catching the base `Exception` class in catch blocks.
9+
* Throw specific exception types (e.g., `ArgumentNullException`, `FormatException`, custom exceptions) rather than generic `System.Exception`.
10+
* Include the parameter name when throwing `ArgumentNullException` using `nameof()`.
11+
12+
2. **Variable Declaration**:
13+
* Never use `var` to declare a variable if the assignment doesn't include the type or the type isn't immediately obvious.
14+
* Use explicit type names for fields, properties, method parameters, and return types.
15+
* Use `var` only when the type is obvious from the right-hand side (e.g., `var user = new User();`).
16+
17+
3. **Null Handling**:
18+
* Validate arguments in public methods and constructors with explicit null checks.
19+
* Use explicit `if (argument == null) throw new ArgumentNullException(nameof(argument));` checks at the beginning of methods/constructors.
20+
* Avoid using the null-forgiving operator (`!`) unless absolutely necessary.
21+
22+
4. **Asynchronous Programming**:
23+
* All async methods should accept a `CancellationToken` as the last parameter.
24+
* Pass the `cancellationToken` down the call stack to all subsequent asynchronous operations.
25+
* Use `Task<T>` or `Task` for asynchronous methods.
26+
27+
5. **LINQ and Collections**:
28+
* Prefer simple, readable LINQ queries.
29+
* Break down complex LINQ queries into separate statements with intermediate variables.
30+
* Use collection interfaces (e.g., `IList<T>`, `IReadOnlyList<T>`) in parameter and return types.
31+
32+
6. **Resource Management**:
33+
* Wrap `IDisposable` instances in `using` statements to ensure proper disposal.
34+
* Implement `IDisposable` correctly if your class manages disposable objects.
35+
36+
7. **Dependency Injection**:
37+
* Use constructor injection for dependencies.
38+
* Store injected dependencies in `private readonly` fields.
39+
* Validate injected dependencies for null in the constructor.
40+
41+
8. **Naming Conventions**:
42+
* Use `PascalCase` for classes, interfaces, enums, methods, properties, and constants.
43+
* Use `camelCase` for local variables and method parameters.
44+
* Prefix private fields with an underscore (`_`).
45+
* Define constants for error messages and other string literals.
46+
47+
9. **Comments**:
48+
* Only add comments when it's not obvious what the code is doing. For example, if a variable name is already fairly descriptive, a comment isn't needed explaining its name.
49+
* Add summary comments to public classes and members of those classes.
50+
51+
## AppConfiguration-Specific Guidelines
52+
53+
1. **Feature Flag Handling**:
54+
* Validate feature flag data structure before processing.
55+
* Handle different feature flag schemas (Microsoft vs .NET) appropriately.
56+
* Use proper error handling when parsing feature flags with clear error messages.
57+
58+
2. **Configuration Key-Value Processing**:
59+
* Follow adapter pattern for processing different configuration types.
60+
* Properly handle key-value pairs with appropriate content type detection.
61+
* Use `KeyValuePair<string, string>` for configuration values.
62+
63+
3. **Content Type Handling**:
64+
* Validate content types before processing.
65+
* Use appropriate content type constants.
66+
* Check content type using extension methods like `IsFeatureFlag()`.
67+
68+
4. **JSON Parsing**:
69+
* Use `Utf8JsonReader` for performance-critical JSON parsing.
70+
* Validate JSON structure and provide clear error messages for malformed input.
71+
* Handle JSON token types appropriately with proper error handling.
72+
73+
5. **Refresh Mechanisms**:
74+
* Implement proper configuration refresh patterns.
75+
* Use sentinel-based refresh mechanisms when appropriate.
76+
* Handle refresh failures gracefully.
77+
78+
## Performance Considerations
79+
80+
1. **String Handling**:
81+
* Use `StringBuilder` for concatenating multiple strings.
82+
* Define string constants for recurring strings.
83+
* Use string interpolation instead of string concatenation when appropriate.
84+
85+
2. **Collections**:
86+
* Initialize collections with estimated capacity when possible.
87+
* Use appropriate collection types for the use case (e.g., `List<T>`, `Dictionary<TKey, TValue>`).
88+
* Avoid unnecessary collection allocations.
89+
90+
3. **Memory Management**:
91+
* Use `Span<T>` and `ReadOnlySpan<T>` for high-performance scenarios.
92+
* Minimize allocations in performance-critical paths.
93+
* Be mindful of closure allocations in LINQ and lambdas.

.github/copilot-instructions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
This is the Azure App Configuration .NET Provider codebase. The service abides by coding guidelines specified in the `github/code-gen-instructions.md` file.
2+
3+
When suggesting code changes, do not modify the files directly. Instead, provide a detailed explanation of the changes you would make and ask for confirmation before editing the files. You may create markdown files to demonstrate the changes you would like to make.

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ on:
1414

1515
permissions:
1616
security-events: write
17+
id-token: write
1718

1819
jobs:
1920
build:
@@ -40,8 +41,17 @@ jobs:
4041
- name: Dotnet Pack
4142
run: pwsh pack.ps1
4243

44+
- name: Azure Login with OIDC
45+
uses: azure/login@v1
46+
with:
47+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
48+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
49+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
50+
4351
- name: Dotnet Test
4452
run: pwsh test.ps1
53+
env:
54+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
4555

4656
- name: Publish Test Results
4757
uses: actions/upload-artifact@v4

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
# Azure Functions localsettings file
77
local.settings.json
88

9+
# Integration test secrets
10+
appsettings.Secrets.json
11+
912
# User-specific files
1013
*.suo
1114
*.user

CodeQL.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
path_classifiers:
2+
docs:
3+
# Documentation
4+
- "examples" # Exclude code samples from scan results
5+
library:
6+
# Library code
7+
- ""
8+
generated:
9+
# Generated code
10+
- ""

0 commit comments

Comments
 (0)