## Description
Add a remarks section to AllowBulkExecution explaining that it is not
recommended to be used with Resource Token authentication
## Type of change
Documentation fix
Fixes https://github.com/Azure/azure-cosmos-dotnet-v3/issues/1783Closes#1783
---------
Co-authored-by: iain holmes <iaholmes@microsoft.com>
Co-authored-by: Ruben Bartelink <ruben@bartelink.com>
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
# Pull Request Template
## Description
Adds a new benchmark to simulate users inserting a document and
immediately reading it. This with the
https://github.com/Azure/azure-cosmos-dotnet-v3/pull/4478 will test
replication latency between different geo regions, and how SDK handles
various error scenarios.
## Type of change
Please delete options that are not relevant.
- [] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [] This change requires a documentation update
## Closing issues
To automatically close an issue: closes #IssueNumber
Co-authored-by: jakewilley_microsoft <--global>
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
# Pull Request Template
## Description
Cleanup of code styling issues in Cosmos.Encryption.Custom.* projects as
set up by editorconfig.
## Type of change
Please delete options that are not relevant.
- [] Bug fix (non-breaking change which fixes an issue)
## Closing issues
Contributes to #4678
---------
Co-authored-by: Juraj Blazek <jublazek@microsoft.com>
Co-authored-by: juraj-blazek <53177060+juraj-blazek@users.noreply.github.com>
Co-authored-by: Santosh Kulkarni <66682828+kr-santosh@users.noreply.github.com>
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
## Description
1. Added `db.query.text` attribute to record queries in Traces.
2. Introduced new `QueryTextMode`, which will have valid values as
a) `None` :Do not show query.
b) `ParameterizedOnly` : Print parameterized query only.
b) `All`
3. It can be set as part of `CosmosClientTelemetryOptions` and
`RequestOptions` (i.e. `QueryRequestOptions` and
`ChangeFeedRequestOptions`)
## Type of change
- [] New feature (non-breaking change which adds functionality)
---------
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
Co-authored-by: Justine Cocchi <jucocchi@microsoft.com>
# Pull Request Template
## Description
On Encryption path we are switching to MDE API with offsets. This allows
reducing of allocations.
To sustain compatibility, enhanced API is backward implemented to
obsoleted local copy of encryption algorithm. No performance
optimizations on obsoleted code paths.
## Type of change
Please delete options that are not relevant.
- [] Bug fix (non-breaking change which fixes an issue)
## Closing issues
Contributes to #4678
---------
Co-authored-by: Juraj Blazek <jublazek@microsoft.com>
Co-authored-by: juraj-blazek <53177060+juraj-blazek@users.noreply.github.com>
Co-authored-by: Santosh Kulkarni <66682828+kr-santosh@users.noreply.github.com>
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
[INTERNAL] CI: Fixes adding auto-retries for tests
Only the failed tests are re-run. Its still possible that that re-run
tests might see the state of the container at that time.
Test needs to be proofed in future.
- Tests updated to clean-up emulator for every class of tests
- It addressed tests non-graceful handling of orphaned containers
- Tests creating unnecessary higher number of partitions are optimized
Reducing the emulator PartitionCount to 20, will help boost emulator
startup times.
Current partition count is 100, its 5x reduction.
NOTE: Why 20, emulator tests have issues at lower partition count (can
be a follow-up)
Side affect:
- Test leaking containers or creating more containers for working-set
will result in failures.
- Preview encryption tests: Authored to be more resilient with container
per test increases overall time 2x (4M -> 8M) (still not the top
bottleneck), we can optimize it later.
Some spot check values (earlier range of 4-8minutes and also flaky)
![{B53E1D28-FE88-43CD-9C98-E2071D994F25}](https://github.com/user-attachments/assets/d9d66859-d343-4c87-b028-26a014bbc2c8)
Overall times with this change
<img width="361" alt="{81CEBD14-A8A3-4795-89ED-8D3F8C6BA1BB}"
src="https://github.com/user-attachments/assets/e1aa4cc0-e8aa-4f5c-8ade-2c6aab75605a">
# Pull Request Template
## Description
Details #4483
The customer wants to validate if one **FeedRange** is a subset of
another **FeedRange**. This means checking if all the data in the y
**FeedRange** is entirely within the boundaries of the x **FeedRange**,
ensuring that no data is processed twice or skipped. It is understood
that **FeedRange** could also be represented by a **PartitionKey** or
**FeedRangeEpk**.
```txt
Feature: PartitionKey and FeedRange Validation
Scenario: Validate if the y (FeedRange) is part of the x (PartitionKey)
Given x represents the PartitionKey
And y represents the FeedRange
And both x and y have inclusive minimum and maximum boundaries (x.IsMinInclusive=true, x.IsMaxInclusive=true, y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is valid, and both x and y include their start and end values
Scenario: Validate NotSupportedException for incompatible boundaries between x (PartitionKey) and y (FeedRange)
Given x represents the PartitionKey
And y represents the FeedRange
And x has an inclusive maximum boundary (x.IsMaxInclusive=true)
And y has an exclusive maximum boundary (y.IsMaxInclusive=false)
When the boundaries are compared
Then a NotSupportedException is thrown due to incompatible boundary configurations
Scenario: Validate minimum boundary inclusiveness for y (FeedRange) when compared to x (PartitionKey)
Given x represents the PartitionKey
And y represents the FeedRange
And y has an exclusive minimum boundary (y.IsMinInclusive=false)
And x has an inclusive minimum boundary (x.IsMinInclusive=true)
When the boundaries are compared
Then an error is thrown because y's minimum value must be inclusive (IsMinInclusive must be true)
Scenario: Validate that both y's (FeedRange) minimum and maximum are exclusive when compared to x (PartitionKey)
Given x represents the PartitionKey
And y represents the FeedRange
And both y's minimum and maximum values are exclusive (y.IsMinInclusive=false, y.IsMaxInclusive=false)
When the boundaries are compared
Then an error is thrown because y's minimum value must be inclusive (IsMinInclusive must be true)
```
| Scenario Description | x.IsMinInclusive | x.IsMaxInclusive |
y.IsMinInclusive | y.IsMaxInclusive | Expected Outcome |
|---------------------------------------------------------------------------------------------------------------|------------------|------------------|------------------|------------------|-----------------------------------------------------------------|
| Validate if the y partition key is part of the x feed range | true |
true | true | true | Scenario is valid, both x and y include their start
and end values |
| Validate NotSupportedException for incompatible boundaries | true |
true | true | false | NotSupportedException is thrown due to
incompatible boundary configurations |
| Validate minimum boundary inclusiveness for y | true | true | false |
true | Error is thrown because y's minimum value must be inclusive |
| Validate y's exclusiveness results in error | true | true | false |
false | Error is thrown because y's minimum value must be inclusive |
---
```txt
Feature: FeedRange and PartitionKey Validation
Scenario: Validate that both x (FeedRange) and y (PartitionKey) are fully inclusive
Given x represents the FeedRange
And y represents the PartitionKey
And x has inclusive minimum and maximum boundaries (x.IsMinInclusive=true, x.IsMaxInclusive=true)
And y has inclusive minimum and maximum boundaries (y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is valid because both x and y include their start and end values
Scenario: Validate that x (FeedRange) has inclusive minimum and exclusive maximum while y (PartitionKey) is fully inclusive
Given x represents the FeedRange
And y represents the PartitionKey
And x has inclusive minimum and exclusive maximum boundaries (x.IsMinInclusive=true, x.IsMaxInclusive=false)
And y has inclusive minimum and maximum boundaries (y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is valid because x and y are compatible in terms of their boundaries
Scenario: Validate that x's (FeedRange) minimum is exclusive while y (PartitionKey) is fully inclusive
Given x represents the FeedRange
And y represents the PartitionKey
And x has an exclusive minimum and inclusive maximum boundary (x.IsMinInclusive=false, x.IsMaxInclusive=true)
And y has inclusive minimum and maximum boundaries (y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is invalid because x's minimum value must be inclusive (IsMinInclusive must be true)
Scenario: Validate that both x's (FeedRange) minimum and maximum are exclusive while y (PartitionKey) is fully inclusive
Given x represents the FeedRange
And y represents the PartitionKey
And x has exclusive minimum and maximum boundaries (x.IsMinInclusive=false, x.IsMaxInclusive=false)
And y has inclusive minimum and maximum boundaries (y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is invalid because x's minimum value must be inclusive (IsMinInclusive must be true)
```
| Scenario Description | x.IsMinInclusive | x.IsMaxInclusive |
y.IsMinInclusive | y.IsMaxInclusive | Expected Outcome |
|---------------------------------------------------------------------------------------------------------------|------------------|------------------|------------------|------------------|-----------------------------------------------------------------|
| Validate that both x and y are fully inclusive | true | true | true |
true | Scenario is valid because both x and y include their start and
end values |
| Validate that x has inclusive minimum and exclusive maximum while y is
fully inclusive | true | false | true | true | Scenario is valid because
x and y are compatible in terms of their boundaries |
| Validate that x's minimum is exclusive while y is fully inclusive |
false | true | true | true | Scenario is invalid because x's minimum
value must be inclusive (IsMinInclusive must be true) |
| Validate that both x's minimum and maximum are exclusive while y is
fully inclusive | false | false | true | true | Scenario is invalid
because x's minimum value must be inclusive (IsMinInclusive must be
true) |
---
```txt
Feature: FeedRange and FeedRange Validation
Scenario: Validate when both x (FeedRange) and y (FeedRange) have inclusive minimum and maximum boundaries
Given x represents the FeedRange
And y represents the FeedRange
And both x and y have inclusive minimum and maximum boundaries (x.IsMinInclusive=true, x.IsMaxInclusive=true, y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is valid because both x and y include their start and end values
Scenario: Validate when x (FeedRange) has inclusive boundaries and y (FeedRange) has an exclusive maximum boundary
Given x represents the FeedRange
And y represents the FeedRange
And x has inclusive minimum and maximum boundaries (x.IsMinInclusive=true, x.IsMaxInclusive=true)
And y has an exclusive maximum boundary (y.IsMinInclusive=true, y.IsMaxInclusive=false)
Then a NotSupportedException is thrown because y's maximum boundary is exclusive while x's is inclusive
Scenario: Validate when x (FeedRange) has inclusive boundaries and y (FeedRange) has an exclusive minimum boundary
Given x represents the FeedRange
And y represents the FeedRange
And x has inclusive minimum and maximum boundaries (x.IsMinInclusive=true, x.IsMaxInclusive=true)
And y has an exclusive minimum boundary (y.IsMinInclusive=false, y.IsMaxInclusive=true)
Then the scenario is invalid because y's minimum boundary must be inclusive
Scenario: Validate when x (FeedRange) has inclusive boundaries and y (FeedRange) has both exclusive minimum and maximum boundaries
Given x represents the FeedRange
And y represents the FeedRange
And x has inclusive minimum and maximum boundaries (x.IsMinInclusive=true, x.IsMaxInclusive=true)
And y has both exclusive minimum and maximum boundaries (y.IsMinInclusive=false, y.IsMaxInclusive=false)
Then the scenario is invalid because y's minimum boundary must be inclusive
Scenario: Validate when x (FeedRange) has an inclusive minimum boundary and an exclusive maximum boundary, and y (FeedRange) has fully inclusive boundaries
Given x represents the FeedRange
And y represents the FeedRange
And x has an inclusive minimum and exclusive maximum boundary (x.IsMinInclusive=true, x.IsMaxInclusive=false)
And y has fully inclusive boundaries (y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is valid because x's and y's boundaries are compatible
Scenario: Validate when both x (FeedRange) and y (FeedRange) have inclusive minimum boundaries and exclusive maximum boundaries
Given x represents the FeedRange
And y represents the FeedRange
And both x and y have inclusive minimum boundaries and exclusive maximum boundaries (x.IsMinInclusive=true, x.IsMaxInclusive=false, y.IsMinInclusive=true, y.IsMaxInclusive=false)
Then the scenario is valid because both ranges are compatible
Scenario: Validate when x (FeedRange) has an inclusive minimum boundary and an exclusive maximum boundary, and y (FeedRange) has an exclusive minimum boundary
Given x represents the FeedRange
And y represents the FeedRange
And x has an inclusive minimum boundary and an exclusive maximum boundary (x.IsMinInclusive=true, x.IsMaxInclusive=false)
And y has an exclusive minimum boundary but an inclusive maximum boundary (y.IsMinInclusive=false, y.IsMaxInclusive=true)
Then the scenario is invalid because y's minimum boundary must be inclusive
Scenario: Validate when x (FeedRange) has an inclusive minimum boundary and an exclusive maximum boundary, and y (FeedRange) has both exclusive minimum and maximum boundaries
Given x represents the FeedRange
And y represents the FeedRange
And x has an inclusive minimum boundary and an exclusive maximum boundary (x.IsMinInclusive=true, x.IsMaxInclusive=false)
And y has both exclusive minimum and maximum boundaries (y.IsMinInclusive=false, y.IsMaxInclusive=false)
Then the scenario is invalid because y's minimum boundary must be inclusive
Scenario: Validate when x (FeedRange) has an exclusive minimum boundary and an inclusive maximum boundary, and y (FeedRange) has fully inclusive boundaries
Given x represents the FeedRange
And y represents the FeedRange
And x has an exclusive minimum boundary and an inclusive maximum boundary (x.IsMinInclusive=false, x.IsMaxInclusive=true)
And y has fully inclusive boundaries (y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is invalid because x's minimum boundary must be inclusive
Scenario: Validate when x (FeedRange) has an exclusive minimum boundary and an inclusive maximum boundary, and y (FeedRange) has an exclusive maximum boundary
Given x represents the FeedRange
And y represents the FeedRange
And x has an exclusive minimum boundary and an inclusive maximum boundary (x.IsMinInclusive=false, x.IsMaxInclusive=true)
And y has an inclusive minimum but an exclusive maximum boundary (y.IsMinInclusive=true, y.IsMaxInclusive=false)
Then the scenario is invalid because x's minimum boundary must be inclusive
Scenario: Validate when both x (FeedRange) and y (FeedRange) have exclusive minimum boundaries and inclusive maximum boundaries
Given x represents the FeedRange
And y represents the FeedRange
And both x and y have exclusive minimum boundaries and inclusive maximum boundaries (x.IsMinInclusive=false, x.IsMaxInclusive=true, y.IsMinInclusive=false, y.IsMaxInclusive=true)
Then the scenario is invalid because both x's and y's minimum boundaries must be inclusive
Scenario: Validate when both x (FeedRange) and y (FeedRange) have exclusive minimum and maximum boundaries
Given x represents the FeedRange
And y represents the FeedRange
And both x and y have exclusive minimum and maximum boundaries (x.IsMinInclusive=false, x.IsMaxInclusive=false, y.IsMinInclusive=false, y.IsMaxInclusive=false)
Then the scenario is invalid because both x's and y's minimum boundaries must be inclusive
Scenario: Validate when x (FeedRange) has exclusive minimum and maximum boundaries, and y (FeedRange) has fully inclusive boundaries
Given x represents the FeedRange
And y represents the FeedRange
And x has exclusive minimum and maximum boundaries (x.IsMinInclusive=false, x.IsMaxInclusive=false)
And y has fully inclusive boundaries (y.IsMinInclusive=true, y.IsMaxInclusive=true)
Then the scenario is invalid because x's minimum boundary must be inclusive
```
| Scenario Description | x.IsMinInclusive | x.IsMaxInclusive |
y.IsMinInclusive | y.IsMaxInclusive | Expected Outcome |
|--------------------------------------------------------------------------------------|------------------|------------------|------------------|------------------|-----------------------------------------------------------|
| Validate when both x and y have inclusive minimum and maximum
boundaries | true | true | true | true | Scenario is valid because both
x and y include their boundaries |
| Validate when x has inclusive boundaries and y has an exclusive
maximum boundary | true | true | true | false | NotSupportedException
because y's maximum is exclusive |
| Validate when x has inclusive boundaries and y has an exclusive
minimum boundary | true | true | false | true | Scenario is invalid
because y's minimum must be inclusive |
| Validate when x has inclusive boundaries and y has both exclusive
minimum and maximum boundaries | true | true | false | false | Scenario
is invalid because y's minimum must be inclusive |
| Validate when x has an inclusive minimum and exclusive maximum, and y
has fully inclusive boundaries | true | false | true | true | Scenario
is valid because x's and y's boundaries are compatible |
| Validate when both x and y have inclusive minimum and exclusive
maximum boundaries | true | false | true | false | Scenario is valid
because both ranges are compatible |
| Validate when x has an inclusive minimum and exclusive maximum, and y
has an exclusive minimum boundary | true | false | false | true |
Scenario is invalid because y's minimum must be inclusive |
| Validate when x has an inclusive minimum and exclusive maximum, and y
has both exclusive boundaries | true | false | false | false | Scenario
is invalid because y's minimum must be inclusive |
| Validate when x has an exclusive minimum and inclusive maximum, and y
has fully inclusive boundaries | false | true | true | true | Scenario
is invalid because x's minimum must be inclusive |
| Validate when x has an exclusive minimum and inclusive maximum, and y
has an exclusive maximum boundary | false | true | true | false |
Scenario is invalid because x's minimum must be inclusive |
| Validate when both x and y have exclusive minimum and inclusive
maximum boundaries | false | true | false | true | Scenario is invalid
because both x's and y's minimum must be inclusive |
| Validate when both x and y have exclusive minimum and maximum
boundaries | false | false | false | false | Scenario is invalid because
both x's and y's minimum must be inclusive |
| Validate when x has exclusive minimum and maximum boundaries, and y
has fully inclusive boundaries | false | false | true | true | Scenario
is invalid because x's minimum must be inclusive |
---
## API
```cs
Task<bool> IsFeedRangePartOfAsync(
Cosmos.FeedRange x,
Cosmos.FeedRange y,
CancellationToken cancellationToken = default)
```
## Levelsetting
### Container
#### Diagram 1: Final state of PR
```mermaid
classDiagram
class Container {
<<abstract>>
+IsFeedRangePartOfAsync() : Task<bool>
}
class ContainerInternal {
+IsFeedRangePartOfAsync() : Task<bool>
}
class ContainerCore {
-container : Container
+IsFeedRangePartOfAsync() : Task<bool>
}
class ContainerInlineCore {
-container : Container
+IsFeedRangePartOfAsync() : Task<bool>
}
class EncryptionContainer {
-container : Container
+IsFeedRangePartOfAsync() : Task<bool>
}
class CustomEncryptionContainer {
-container : Container
+IsFeedRangePartOfAsync() : Task<bool>
}
ContainerInternal --|> Container : "is a"
ContainerCore --|> ContainerInternal : "is a"
ContainerInlineCore --|> ContainerCore : "is a"
EncryptionContainer --|> Container : "is a"
CustomEncryptionContainer --|> Container : "is a"
ContainerCore --> Container : "has a"
ContainerInlineCore --> Container : "has a"
EncryptionContainer --> Container : "has a"
CustomEncryptionContainer --> Container : "has a"
```
### FeedRange
```mermaid
classDiagram
class FeedRange {
<<abstract>>
}
class FeedRangeInternal {
-range : Range
}
class FeedRangeEpk {
-range : Range
}
class FeedRangePartitionKey {
-range : Range
}
class FeedRangePartitionKeyRange {
-range : Range
}
class Range {
+Min : string
+Max : string
+IsMinInclusive : bool
+IsMaxInclusive : bool
}
FeedRangeInternal --|> FeedRange : "is a"
FeedRangeEpk --|> FeedRangeInternal : "is a"
FeedRangePartitionKey --|> FeedRangeInternal : "is a"
FeedRangePartitionKeyRange --|> FeedRangeInternal : "is a"
FeedRangeInternal --> Range : "has a"
FeedRangePartitionKeyRange --> Range : "has a"
FeedRangePartitionKey --> Range : "has a"
FeedRangeEpk --> Range : "has a"
```
https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.feedrange?view=azure-dotnet
A **FeedRange** in Azure Cosmos DB represents a segment of data, often
based on partition keys, that can be processed or monitored.
**FeedRanges** are typically used in the context of change feed
processing to allow multiple workers to consume data in parallel by
splitting the container’s data into smaller, manageable pieces. Each
**FeedRange** corresponds to a specific partition key range.
**Min**: Lower boundary of a range
**Max** Upper boundary of a range
**IsMinInclusive**: Is the lower boundary inclusive or exclusive?
- if _true_, the partition key value at Min is included in the range.
- if _false_, the range starts just after the Min value.
**IsMaxInclusive**: Is the upper boundary inclusive or exclusive?
- if _true_, the partition key at Max is included in the range.
- if _false_, the range stops just before the Max value.
**"MaxExclusive"**: The upper boundary of a range is exclusive; the
range does not include the maximum value itself.
- _IsMaxInclusive = false_ means that the upper boundary is exclusive,
so **IsMaxInclusive** is that same as the unofficial term,
"MaxExclusive".
## Examples based on unit tests
### FeedRange
A FeedRange represents a segment of data that can be processed or read
in parallel. FeedRanges can be used with or without partition keys,
depending on the context. They are especially useful in change feed
processing, where multiple workers can process different ranges in
parallel.
```cs
Container container = default;
try
{
ContainerResponse containerResponse = await this.cosmosDatabase.CreateContainerIfNotExistsAsync(
id: Guid.NewGuid().ToString(),
partitionKeyPath: "/pk");
container = containerResponse.Container;
bool actualIsSubset = await container.IsFeedRangePartOfAsync(
new FeedRangeEpk(new Documents.Routing.Range<string>(xMin, xMax, true, false)),
new FeedRangeEpk(new Documents.Routing.Range<string>(yMin, yMax, true, false)),
cancellationToken: CancellationToken.None);
Assert.AreEqual(expected: expectedIsSubset, actual: actualIsSubset);
}
finally
{
if (container != null)
{
await container.DeleteContainerAsync();
}
}
```
### Hierarchical PartitionKey
In hierarchical partitioning, the partition key is composed of multiple
levels (or paths), which can be combined in a hierarchical manner. This
means that data is partitioned based on a combination of keys, such as
{"region": "US", "userId": "123"}, which makes the partitioning more
granular and allows for more specific partition key ranges.
```cs
Container container = default;
try
{
ContainerProperties containerProperties = new ContainerProperties()
{
Id = Guid.NewGuid().ToString(),
PartitionKeyPaths = new Collection<string> { "/pk", "/id" }
};
ContainerResponse containerResponse = await this.cosmosDatabase.CreateContainerIfNotExistsAsync(containerProperties);
container = containerResponse.Container;
PartitionKey partitionKey = new PartitionKeyBuilder()
.Add("WA")
.Add(Guid.NewGuid().ToString())
.Build();
FeedRange feedRange = FeedRange.FromPartitionKey(partitionKey);
bool actualIsSubset = await container.IsFeedRangePartOfAsync(
new FeedRangeEpk(new Documents.Routing.Range<string>(xMin, xMax, true, false)),
feedRange,
cancellationToken: CancellationToken.None);
Assert.AreEqual(expected: expectedIsSubset, actual: actualIsSubset);
}
finally
{
if (container != null)
{
await container.DeleteContainerAsync();
}
}
```
### Partition Key
In non-hierarchical partitioning, the partition key is a single value
(or path). For instance, a partition key might be {"userId": "123"}.
Data is distributed based solely on this one-dimensional key.
```cs
Container container = default;
try
{
ContainerResponse containerResponse = await this.cosmosDatabase.CreateContainerIfNotExistsAsync(
id: Guid.NewGuid().ToString(),
partitionKeyPath: "/pk");
container = containerResponse.Container;
PartitionKey partitionKey = new("WA");
FeedRange feedRange = FeedRange.FromPartitionKey(partitionKey);
bool actualIsSubset = await container.IsFeedRangePartOfAsync(
new FeedRangeEpk(new Documents.Routing.Range<string>(xMin, xMax, true, false)),
feedRange,
cancellationToken: CancellationToken.None);
Assert.AreEqual(expected: expectedIsSubset, actual: actualIsSubset);
}
finally
{
if (container != null)
{
await container.DeleteContainerAsync();
}
}
```
### Invalid FeedRangeEpk with IsMinInclusive: false throws
ArgumentOutOfRangeException
FeedRangeEpk is a more specific form of FeedRange that focuses on
effective partition keys (EPK), which represent the internal structure
of how data is distributed across partitions in Azure Cosmos DB.
FeedRangeEpk targets specific physical partitions, and these boundaries
are managed internally by Cosmos DB. These boundaries are fixed based on
the hash values of the partition keys and are not modifiable by the
user. As a result, there is no need for the notion of inclusivity,
because the partition boundary is rigid and defined by the physical
partition structure, not by a logical partition key.
``` cs
Container container = default;
try
{
ContainerResponse containerResponse = await this.cosmosDatabase.CreateContainerIfNotExistsAsync(
id: Guid.NewGuid().ToString(),
partitionKeyPath: "/pk");
container = containerResponse.Container;
bool actualIsSubset = await container
.IsFeedRangePartOfAsync(
new FeedRangeEpk(new Documents.Routing.Range<string>("", "3FFFFFFFFFFFFFFF", false, true)),
new FeedRangeEpk(new Documents.Routing.Range<string>("", "FFFFFFFFFFFFFFFF", true, false)),
cancellationToken: CancellationToken.None));
}
catch (ArgumentOutOfRangeException exception)
{
Console.WriteLine(exception.Message); // "IsMinInclusive must be true."
}
finally
{
if (container != null)
{
await container.DeleteContainerAsync();
}
}
```
### EnsureConsistentInclusitivy
Validates if all ranges in the list have consistent inclusivity for both
IsMinInclusive and IsMaxInclusive boundaries.
Throws an InvalidOperationException if there are inconsistencies.
```cs
List<Documents.Routing.Range<string>> ranges = new List<Documents.Routing.Range<string>>
{
new Documents.Routing.Range<string> { IsMinInclusive = true, IsMaxInclusive = false },
new Documents.Routing.Range<string> { IsMinInclusive = true, IsMaxInclusive = true },
new Documents.Routing.Range<string> { IsMinInclusive = true, IsMaxInclusive = false },
new Documents.Routing.Range<string> { IsMinInclusive = false, IsMaxInclusive = false }
};
EnsureConsistentInclusivity(ranges);
```
### IsSubset
Determines whether the y range is a subset of the x range.
```cs
Documents.Routing.Range<string> x= new Documents.Routing.Range<string>("A", "Z", true, true);
Documents.Routing.Range<string> y= new Documents.Routing.Range<string>("B", "Y", true, true);
bool isSubset = ContainerCore.IsSubset(x, y);
```
## Type of change
Please delete options that are not relevant.
- [x] New feature (non-breaking change which adds functionality)
- [x] This change requires a documentation update
## Closing issues
To automatically close an issue: closes#4483
---------
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
[D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA007: Method ClientRetryPolicy_Retry_SingleMaster_Read_PreferredLocations defined in class Microsoft.Azure.Cosmos.Client.Tests.ClientRetryPolicyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA007: Method ClientRetryPolicy_Retry_MultiMaster_Read_PreferredLocations defined in class Microsoft.Azure.Cosmos.Client.Tests.ClientRetryPolicyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA007: Method ClientRetryPolicy_Retry_MultiMaster_Write_PreferredLocations defined in class Microsoft.Azure.Cosmos.Client.Tests.ClientRetryPolicyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA007: Method ClientRetryPolicy_NoRetry_SingleMaster_Write_PreferredLocations defined in class Microsoft.Azure.Cosmos.Client.Tests.ClientRetryPolicyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA007: Method ClientRetryPolicy_NoRetry_SingleMaster_Read_NoPreferredLocations defined in class Microsoft.Azure.Cosmos.Client.Tests.ClientRetryPolicyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA007: Method ClientRetryPolicy_NoRetry_SingleMaster_Write_NoPreferredLocations defined in class Microsoft.Azure.Cosmos.Client.Tests.ClientRetryPolicyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA007: Method ClientRetryPolicy_NoRetry_MultiMaster_Read_NoPreferredLocations defined in class Microsoft.Azure.Cosmos.Client.Tests.ClientRetryPolicyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA007: Method ClientRetryPolicy_NoRetry_MultiMaster_Write_NoPreferredLocations defined in class Microsoft.Azure.Cosmos.Client.Tests.ClientRetryPolicyTests does not have correct signature. Test method marked with the [TestMethod] attribute must be non-static, public, return-type as void and should not take any parameter. Example: public void Test.Class1.Test(). Additionally, if you are using async-await in test method then return-type must be Task. Example: public async Task Test.Class1.Test2()
There are still some more query test issues that needs attention (next follow-UpsertUser)
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA001: TestClass attribute defined on non-public class Microsoft.Azure.Cosmos.Tests.Query.OrderByQueryPartitionRangePageAsyncEnumeratorTests+Implementation
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA001: TestClass attribute defined on non-public class Microsoft.Azure.Cosmos.Tests.Query.QueryPartitionRangePageAsyncEnumeratorTests+Implementation
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA001: TestClass attribute defined on non-public class Microsoft.Azure.Cosmos.Tests.Pagination.BufferedPartitionPartitionRangeEnumeratorTests+Implementation
[MSTest][Discovery][D:\a\1\s\Microsoft.Azure.Cosmos\tests\Microsoft.Azure.Cosmos.Tests\bin\Debug\net6.0\Microsoft.Azure.Cosmos.Tests.dll] UTA001: TestClass attribute defined on non-public class Microsoft.Azure.Cosmos.Tests.Pagination.SinglePartitionPartitionRangeEnumeratorTests+Implementation
[INTERNAL] UnitTest: Regions type public fields validation
Broken for (Germany Central) and (Germany Northeast).
Needs Direct package upgrade with the fix.
# Pull Request Template
## Description
1. Switch frequent constants string comparison mode to `ordinal`
2. Reduce allocations and validations complexity
## Type of change
Please delete options that are not relevant.
- [] Bug fix (non-breaking change which fixes an issue)
## Closing issues
Contributes to #4678
## Description
Adds an aggregate operator for CountIf. Removes debug assert from
QueryPartitionProvider that is no longer relevant
## Type of change
- [x] New feature (non-breaking change which adds functionality)
# Pull Request Template
## Description
Adding documentation to Replace patch operation to describe the
following scenario:
```txt
Scenario: Replace operation on a non-existent property
Given a Cosmos container with an item
And the item is created with an "id", "name", and "description"
When a Replace PatchOperation is attempted on a non-existent property "/fake/item"
Then the operation should throw a CosmosException
And the HTTP status code should be 400 BadRequest
```
## Type of change
Please delete options that are not relevant.
- [] Bug fix (non-breaking change which fixes an issue)
- [] New feature (non-breaking change which adds functionality)
- [] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [] This change requires a documentation update
## Closing issues
To automatically close an issue: closes#4613
---------
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
# Pull Request Template
## Description
Updating benchmark results after upgrade of
`Microsoft.Data.Encryption.Cryptography` dependency to version 1.2.0.
## Type of change
Please delete options that are not relevant.
- [] New feature (non-breaking change which adds functionality)
## Closing issues
Contributes to the closure of an issue: #4675
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
# Pull Request Template
## Description
Switches usages of `JsonTextReader` and `JsonTextWriter` to use
`ArrayPool<char>.Shared` for better performance and reduced memory
allocations. Arrays returned to pool are zeroed for increased data
security (at benchmarked cost of ~3.5% extra mean compared to non-zeroed
returns).
## Type of change
Please delete options that are not relevant.
- [] Bug fix (non-breaking change which fixes an issue)
## Closing issues
Contributes to #4678
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
# Pull Request Template
## Description
Updates the `Microsoft.Data.Encryption.Cryptography` dependency to
version 1.2.0. This unblocks the release of stable version of the
`Microsoft.Azure.Cosmos.Encryption.Custom` package.
See also [the release
notes](https://github.com/Azure/microsoft-data-encryption-sdk/blob/main/net/release-notes/README.md)
for more information about the update.
## Type of change
Please delete options that are not relevant.
- [X] New feature (non-breaking change which adds functionality)
## Closing issues
Unblocks the closure of an issue: #4675
---------
Co-authored-by: Santosh Kulkarni <66682828+kr-santosh@users.noreply.github.com>
Co-authored-by: Jan Hyka <jahyka@microsoft.com>
Co-authored-by: Jan Hyka <38495542+JanHyka@users.noreply.github.com>
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
## Description
Adds deserialization of HybridSearchQueryInfo to the query plan.
## Type of change
Please delete options that are not relevant.
- [x] New feature (non-breaking change which adds functionality)
# Pull Request Template
## Description
Adding a `Microsoft.Azure.Cosmos.Encryption.Custom.Performance.Tests`
with `Encrypt`/`Decrypt` benchmarks for different document size.
Attaching also initial baseline report with the current memory
allocations.
## Type of change
Please delete options that are not relevant.
- [x] New feature (non-breaking change which adds functionality)
## Closing issues
Contributes to #4678
---------
Co-authored-by: Santosh Kulkarni <66682828+kr-santosh@users.noreply.github.com>
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
# Pull Request Template
## Description
Documentation shows **ReadItemAsync** is returning type _ToDoActivity_
instead of _ItemResponse<ToDoActivity>_
## Type of change
Please delete options that are not relevant.
- [] Bug fix (non-breaking change which fixes an issue)
- [] New feature (non-breaking change which adds functionality)
- [] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [] This change requires a documentation update
## Closing issues
To automatically close an issue: closes #IssueNumber
---------
Co-authored-by: Kiran Kumar Kolli <kirankk@microsoft.com>
* [INTERNAL] Changelog: Add note about Newtonsoft.Json (10.0.3) secuirty vulnerability and upgrade to latest patched version
* Update changelog.md
Co-authored-by: Kevin Pilch <kevinpi@microsoft.com>
---------
Co-authored-by: Kevin Pilch <kevinpi@microsoft.com>
* Initial code changes to throw 503 on 429/3092.
* Updated client retry policy. Added more tests to cover 429/3092.
* Code changes to update direct package version. Updating the tests.
* Code changes to refactor client retry policy.
* Minor code cleanup.
* Reverting the direct version bump up change.
* Code changes to address some of the review comments.
* Code changes to move failover logic in client retry policy.
* Minor code clean up.
* Code changes to clean up some cosmetic items.
* Further clean up.
* Code changes to address review comments.
* Minor refactor to address cosmetic update.
* Code changes to address cosmetic review comment.
* test improvements
* fixed other multiregion test
* requested changes
* test fix
* adds util function for multiregion setup
* fixed util method/class
* parallelize tasks
* checkin in
* support for both STJ and NSJ
* update contracts.
* name change PreviousLsn
* STJ TypeConverter support for ChangeFeedMetadata
* adding bacl StringEnumConverter
* test for Writes ChangeFeedMetadata
* removing DateTimeOffset as results are inconsistent.
* trying to get GMT, not local
* static UnixEpoch
* static qualifier in tests
* PropertyNameCaseInsensitive = false tests. copy of True tests.
* setting PropertyNameCaseInsensitive correctly for tests
* removed duplication for propertyNameCaseInsensitive tests
* remove JsonStringEnumConverter(), from tests
---------
Co-authored-by: Matias Quaranta <ealsur@users.noreply.github.com>
* changed hedge region to only show sucessfull region
* added and updated tests
* discussion changes
* suggestions and test improvements
* test fix
* updated hedge context
* fix test
* no string conversion
* requested changes
* suggested changes
* remove and sort usings