From 1a974b84e66b9336919cbca4b9daedec75751086 Mon Sep 17 00:00:00 2001 From: jakewilley_microsoft <--global> Date: Thu, 9 May 2024 16:57:56 -0400 Subject: [PATCH 1/2] Benchmark: Add region to configuration --- .../Tools/Benchmark/BenchmarkConfig.cs | 10 +++++++++- .../Tools/Benchmark/README.md | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs index 2c523374bf..eaa511c547 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs @@ -141,6 +141,9 @@ public class BenchmarkConfig [Option(Required = false, HelpText = "Enable Client Telemetry Feature in SDK. Make sure you enable it from the portal also.")] public bool EnableTelemetry { get; set; } = false; + [Option(Required = false, HelpText = "List of comma separated preferred regions.")] + public string ApplicationPreferredRegions { get; set; } = null; + internal int GetTaskCount(int containerThroughput) { int taskCount = this.DegreeOfParallelism; @@ -224,9 +227,14 @@ internal Microsoft.Azure.Cosmos.CosmosClient CreateCosmosClient(string accountKe { DisableSendingMetricsToService = !this.EnableTelemetry, DisableDistributedTracing = !this.EnableDistributedTracing - } + }, }; + if(!string.IsNullOrEmpty(this.ApplicationPreferredRegions)) + { + clientOptions.ApplicationPreferredRegions = this.ApplicationPreferredRegions.Split(','); + } + if (!string.IsNullOrWhiteSpace(this.ConsistencyLevel)) { clientOptions.ConsistencyLevel = (Microsoft.Azure.Cosmos.ConsistencyLevel)Enum.Parse(typeof(Microsoft.Azure.Cosmos.ConsistencyLevel), this.ConsistencyLevel, ignoreCase: true); diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/README.md b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/README.md index afbaf84bc6..9b728a447b 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/README.md +++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/README.md @@ -121,6 +121,7 @@ Copyright (C) 2019 CosmosBenchmark --resultskey Key to publish results to --resultsdatabase Database to publish results to --resultscontainer Container to publish results to + --applicationpreferredregions List of comma seperated preferred regions --help Display this help screen. --version Display version information. ``` From 00beaa866e2e8f61018b08d61b64e2b227226d96 Mon Sep 17 00:00:00 2001 From: jakewilley_microsoft <--global> Date: Mon, 13 May 2024 13:05:36 -0400 Subject: [PATCH 2/2] Trim the region names --- .../Tools/Benchmark/BenchmarkConfig.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs index eaa511c547..6d02c40f79 100644 --- a/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs +++ b/Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs @@ -230,9 +230,10 @@ internal Microsoft.Azure.Cosmos.CosmosClient CreateCosmosClient(string accountKe }, }; - if(!string.IsNullOrEmpty(this.ApplicationPreferredRegions)) + if (!string.IsNullOrEmpty(this.ApplicationPreferredRegions)) { - clientOptions.ApplicationPreferredRegions = this.ApplicationPreferredRegions.Split(','); + clientOptions.ApplicationPreferredRegions = this.ApplicationPreferredRegions.Split(',') + .Select(region => region.Trim()).ToArray(); } if (!string.IsNullOrWhiteSpace(this.ConsistencyLevel))