Skip to content

Commit 6286b22

Browse files
Merge branch 'master' into copilot/fix-unconditional-dll-copying
2 parents b96bb10 + 28ac0da commit 6286b22

36 files changed

Lines changed: 1653 additions & 622 deletions

.github/copilot-instructions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ Purpose: quick, actionable context so an AI coding assistant can be immediately
4141

4242
- **How AI should produce code/changes here**:
4343
- **🚫 HARD RULE: NEVER push directly to `master` — NO EXCEPTIONS.** Always create a feature branch and submit a pull request. This rule cannot be overridden.
44+
- **Branch naming**: Always use the format `users/<user-name>/feature-name` (e.g. `users/ntripician/fix-retry-logic`). Do not use other conventions like `feature/`, `fix/`, or `dev/`.
45+
- **PR title format**: All pull request titles **must** match the CI lint regex: `(\[Internal\]|\[v4\] )?.{3}.+: (Adds|Fixes|Refactors|Removes) .{3}.+`. The format is `[Optional Prefix] Category: Verb Description` where the verb is one of `Adds`, `Fixes`, `Refactors`, or `Removes`. Optional prefixes are `[Internal]` (for PRs with no customer impact) or `[v4]` (for v4-specific changes). Examples:
46+
- `Diagnostics: Adds GetElapsedClientLatency to CosmosDiagnostics`
47+
- `PartitionKey: Fixes null reference when using default(PartitionKey)`
48+
- `[v4] Client Encryption: Refactors code to external project`
49+
- `[Internal] Query: Adds code generator for CosmosNumbers for easy additions in the future`
4450
- Keep changes minimal and focused; prefer small, targeted edits and follow existing code style.
4551
- When suggesting build/test changes, reference the relevant MSBuild property or pipeline YAML (point to `Directory.Build.props` or `templates/*`).
4652
- Do not change version numbers or packaging settings without explicit instruction — these are centrally managed.

Microsoft.Azure.Cosmos/FaultInjection/tests/FaultInjectionBuilderValidationTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public void EndpointBuilder_ValidParams_Succeeds()
379379
Assert.IsNotNull(endpoint);
380380
Assert.AreEqual(3, endpoint.GetReplicaCount());
381381
Assert.IsFalse(endpoint.IsIncludePrimary());
382-
Assert.AreEqual("dbs/db/colls/col", endpoint.GetResoureName());
382+
Assert.AreEqual("dbs/db/colls/col", endpoint.GetResourceName());
383383
}
384384

385385
#endregion

Microsoft.Azure.Cosmos/src/Authorization/AuthorizationTokenProvider.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ public abstract ValueTask<string> GetUserAuthorizationTokenAsync(
5252
AuthorizationTokenType tokenType,
5353
ITrace trace);
5454

55-
public abstract ValueTask AddInferenceAuthorizationHeaderAsync(
56-
INameValueCollection headersCollection,
57-
Uri requestAddress,
58-
string verb,
59-
AuthorizationTokenType tokenType);
60-
6155
public abstract void TraceUnauthorized(
6256
DocumentClientException dce,
6357
string authorizationToken,

Microsoft.Azure.Cosmos/src/Authorization/AuthorizationTokenProviderMasterKey.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,6 @@ private void Dispose(bool disposing)
214214
this.authKeyHashFunction = null;
215215
}
216216

217-
public override ValueTask AddInferenceAuthorizationHeaderAsync(INameValueCollection headersCollection, Uri requestAddress, string verb, AuthorizationTokenType tokenType)
218-
{
219-
throw new NotImplementedException("AddInferenceAuthorizationHeaderAsync is only valid for AAD");
220-
}
221-
222217
// Use C# finalizer syntax for finalization code.
223218
// This finalizer will run only if the Dispose method does not get called.
224219
// It gives your base class the opportunity to finalize.

Microsoft.Azure.Cosmos/src/Authorization/AuthorizationTokenProviderResourceToken.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,6 @@ private void Dispose(bool disposing)
9292
// Do nothing
9393
}
9494

95-
public override ValueTask AddInferenceAuthorizationHeaderAsync(INameValueCollection headersCollection, Uri requestAddress, string verb, AuthorizationTokenType tokenType)
96-
{
97-
throw new NotImplementedException("AddInferenceAuthorizationHeaderAsync is only valid for AAD");
98-
}
99-
10095
// Use C# finalizer syntax for finalization code.
10196
// This finalizer will run only if the Dispose method does not get called.
10297
// It gives your base class the opportunity to finalize.

Microsoft.Azure.Cosmos/src/Authorization/AuthorizationTokenProviderTokenCredential.cs

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace Microsoft.Azure.Cosmos
1515

1616
internal sealed class AuthorizationTokenProviderTokenCredential : AuthorizationTokenProvider
1717
{
18-
private const string InferenceTokenPrefix = "Bearer ";
1918
internal readonly TokenCredentialCache tokenCredentialCache;
2019
private bool isDisposed = false;
2120

@@ -24,13 +23,15 @@ internal sealed class AuthorizationTokenProviderTokenCredential : AuthorizationT
2423
public AuthorizationTokenProviderTokenCredential(
2524
TokenCredential tokenCredential,
2625
Uri accountEndpoint,
27-
TimeSpan? backgroundTokenCredentialRefreshInterval)
26+
TimeSpan? backgroundTokenCredentialRefreshInterval,
27+
Func<string, string> tokenToAuthorizationHeader)
2828
{
2929
this.tokenCredential = tokenCredential ?? throw new ArgumentNullException(nameof(tokenCredential));
3030
this.tokenCredentialCache = new TokenCredentialCache(
3131
tokenCredential: tokenCredential,
3232
accountEndpoint: accountEndpoint,
33-
backgroundTokenCredentialRefreshInterval: backgroundTokenCredentialRefreshInterval);
33+
backgroundTokenCredentialRefreshInterval: backgroundTokenCredentialRefreshInterval,
34+
tokenToAuthorizationHeader: tokenToAuthorizationHeader ?? throw new ArgumentNullException(nameof(tokenToAuthorizationHeader)));
3435
}
3536

3637
public override async ValueTask<(string token, string payload)> GetUserAuthorizationAsync(
@@ -42,8 +43,7 @@ public AuthorizationTokenProviderTokenCredential(
4243
{
4344
using (Trace trace = Trace.GetRootTrace(nameof(GetUserAuthorizationTokenAsync), TraceComponent.Authorization, TraceLevel.Info))
4445
{
45-
string token = AuthorizationTokenProviderTokenCredential.GenerateAadAuthorizationSignature(
46-
await this.tokenCredentialCache.GetTokenAsync(trace));
46+
string token = await this.tokenCredentialCache.GetTokenAuthorizationHeaderAsync(trace);
4747
return (token, default);
4848
}
4949
}
@@ -56,8 +56,7 @@ public override async ValueTask<string> GetUserAuthorizationTokenAsync(
5656
AuthorizationTokenType tokenType,
5757
ITrace trace)
5858
{
59-
return AuthorizationTokenProviderTokenCredential.GenerateAadAuthorizationSignature(
60-
await this.tokenCredentialCache.GetTokenAsync(trace));
59+
return await this.tokenCredentialCache.GetTokenAuthorizationHeaderAsync(trace);
6160
}
6261

6362
public override async ValueTask AddAuthorizationHeaderAsync(
@@ -68,28 +67,12 @@ public override async ValueTask AddAuthorizationHeaderAsync(
6867
{
6968
using (Trace trace = Trace.GetRootTrace(nameof(GetUserAuthorizationTokenAsync), TraceComponent.Authorization, TraceLevel.Info))
7069
{
71-
string token = AuthorizationTokenProviderTokenCredential.GenerateAadAuthorizationSignature(
72-
await this.tokenCredentialCache.GetTokenAsync(trace));
70+
string token = await this.tokenCredentialCache.GetTokenAuthorizationHeaderAsync(trace);
7371

7472
headersCollection.Add(HttpConstants.HttpHeaders.Authorization, token);
7573
}
7674
}
7775

78-
public override async ValueTask AddInferenceAuthorizationHeaderAsync(
79-
INameValueCollection headersCollection,
80-
Uri requestAddress,
81-
string verb,
82-
AuthorizationTokenType tokenType)
83-
{
84-
using (Trace trace = Trace.GetRootTrace(nameof(GetUserAuthorizationTokenAsync), TraceComponent.Authorization, TraceLevel.Info))
85-
{
86-
string token = await this.tokenCredentialCache.GetTokenAsync(trace);
87-
88-
string inferenceToken = $"{InferenceTokenPrefix}{token}";
89-
headersCollection.Add(HttpConstants.HttpHeaders.Authorization, inferenceToken);
90-
}
91-
}
92-
9376
public override void TraceUnauthorized(
9477
DocumentClientException dce,
9578
string authorizationToken,

Microsoft.Azure.Cosmos/src/Authorization/AzureKeyCredentialAuthorizationTokenProvider.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,5 @@ private void CheckAndRefreshTokenProvider()
125125
}
126126
}
127127
}
128-
129-
public override ValueTask AddInferenceAuthorizationHeaderAsync(INameValueCollection headersCollection, Uri requestAddress, string verb, AuthorizationTokenType tokenType)
130-
{
131-
throw new NotImplementedException("AddInferenceAuthorizationHeaderAsync is only valid for AAD");
132-
}
133128
}
134129
}

0 commit comments

Comments
 (0)