コード例 #1
0
        /// <summary>
        /// Automatically populates the <see cref="PreferredLocations"/> for geo-replicated database accounts in the Azure Cosmos DB service,
        /// based on the current region that the client is running in.
        /// </summary>
        /// <param name="location">The current region that this client is running in. E.g. "East US" </param>
        public void SetCurrentLocation(string location)
        {
            if (!RegionProximityUtil.SourceRegionToTargetRegionsRTTInMs.ContainsKey(location))
            {
                throw new ArgumentException("Current location is not a valid Azure region.");
            }

            List <string> proximityBasedPreferredLocations = RegionProximityUtil.GeneratePreferredRegionList(location);

            if (proximityBasedPreferredLocations != null)
            {
                this.preferredLocations.Clear();
                foreach (string preferredLocation in proximityBasedPreferredLocations)
                {
                    this.preferredLocations.Add(preferredLocation);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Automatically populates the <see cref="PreferredLocations"/> for geo-replicated database accounts in the Azure Cosmos DB service,
        /// based on the current region that the client is running in.
        /// </summary>
        /// <param name="location">The current region that this client is running in. E.g. "East US" </param>
        public void SetCurrentLocation(string location)
        {
            if (!RegionProximityUtil.SourceRegionToTargetRegionsRTTInMs.ContainsKey(location))
            {
                throw new ArgumentException($"ApplicationRegion configuration '{location}' is not a valid Azure region or the current SDK version does not recognize it. If the value represents a valid region, make sure you are using the latest SDK version.");
            }

            List <string> proximityBasedPreferredLocations = RegionProximityUtil.GeneratePreferredRegionList(location);

            if (proximityBasedPreferredLocations != null)
            {
                this.preferredLocations.Clear();
                foreach (string preferredLocation in proximityBasedPreferredLocations)
                {
                    this.preferredLocations.Add(preferredLocation);
                }
            }
        }