Skip to content

Commit 2113c69

Browse files
authored
Merge pull request #199 from philnach/limittoendpoint
Add LimitToEndpoint setting addressing Exporting from JSON to Containerized cosmos db local not working as expected
2 parents dd15711 + b1f5522 commit 2113c69

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosExtensionServices.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public static CosmosClient CreateClient(CosmosSettingsBase settings, string disp
3333
AllowBulkExecution = true,
3434
EnableContentResponseOnWrite = false,
3535
Serializer = cosmosSerializer,
36+
LimitToEndpoint = settings.LimitToEndpoint,
3637
};
3738

3839
if (!string.IsNullOrEmpty(settings.WebProxy)){

Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosSettingsBase.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ public abstract class CosmosSettingsBase : IValidatableObject
1616
public string? AccountEndpoint { get; set; }
1717
public bool EnableInteractiveCredentials { get; set; }
1818
public bool InitClientEncryption { get; set; } = false;
19+
20+
/// <summary>
21+
/// <see cref="CosmosClientOptions.LimitToEndpoint"/>
22+
/// When running the Azure Cosmos DB emulator in a Linux Container on Windows
23+
/// a value of false results in failure to connect to Cosmos DB emulator.
24+
/// </summary>
25+
public bool LimitToEndpoint { get; set; } = false;
1926

2027
public virtual IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
2128
{

Extensions/Cosmos/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ Or with RBAC:
8585
- `Gateway` (default)
8686
- `Direct`
8787

88+
- **`LimitToEndpoint`**: Optional, defaults to `false`. When the value of this property is false, the Cosmos DB SDK will automatically discover
89+
write and read regions, and use them when the configured application region is not available.
90+
When set to `true`, availability is limited to the endpoint specified.
91+
- **Note**: [CosmosClientOptions.LimitToEndpoint Property](https://learn.microsoft.com/dotnet/api/microsoft.azure.cosmos.cosmosclientoptions.limittoendpoint?view=azure-dotnet). When using the Cosmos DB Emulator Container for Linux it's been observed
92+
setting the value to `true` enables import and export of data.
93+
8894
#### **Serverless Account**
8995
- **`IsServerlessAccount`**: Specifies whether the target account uses Serverless instead of Provisioned throughput, which affects the way containers are created.
9096
- **Note**: Serverless accounts cannot have shared throughput. See [Azure Cosmos DB serverless account type](https://learn.microsoft.com/azure/cosmos-db/serverless#use-serverless-resources).
@@ -115,6 +121,7 @@ Or with RBAC:
115121
"IgnoreNullValues": false,
116122
"IsServerlessAccount": false,
117123
"UseSharedThroughput": false,
118-
"InitClientEncryption": false
124+
"InitClientEncryption": false,
125+
"LimitToEndpoint": false
119126
}
120127
```

0 commit comments

Comments
 (0)