From 07ef52aad6927cf23d3da488a27a8e692389ead4 Mon Sep 17 00:00:00 2001 From: Rodrigo Brandao Date: Wed, 22 Apr 2026 12:17:17 -0700 Subject: [PATCH 01/12] Removing confusing field from CosmosDBStorageConfig --- .../storage/cosmos/cosmos_db_storage.py | 54 +++++++++++-------- .../cosmos/cosmos_db_storage_config.py | 7 +-- .../storage_cosmos/test_cosmos_db_storage.py | 4 +- 3 files changed, 35 insertions(+), 30 deletions(-) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py index 5dc612737..5867e4f66 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py @@ -52,33 +52,41 @@ def __init__(self, config: CosmosDBStorageConfig): self._lock: asyncio.Lock = asyncio.Lock() def _create_client(self) -> CosmosClient: - if self._config.url: - if not self._config.credential: - raise ValueError( - storage_errors.InvalidConfiguration.format( - "Credential is required when using a custom service URL" - ) + + if not self._config.cosmos_db_endpoint: + raise ValueError( + storage_errors.InvalidConfiguration.format( + "Cosmos DB Endpoint is required." ) - return CosmosClient( - url=self._config.url, credential=self._config.credential ) - connection_policy = self._config.cosmos_client_options.get( - "connection_policy", documents.ConnectionPolicy() - ) + if self._config.credential or self._config.auth_key: + cred = ( + self._config.credential + if self._config.credential + else self._config.auth_key + ) - # kwargs 'connection_verify' is to handle CosmosClient overwriting the - # ConnectionPolicy.DisableSSLVerification value. - return CosmosClient( - self._config.cosmos_db_endpoint, - self._config.auth_key, - consistency_level=self._config.cosmos_client_options.get( - "consistency_level", None - ), - **{ - "connection_policy": connection_policy, - "connection_verify": not connection_policy.DisableSSLVerification, - }, + connection_policy = self._config.cosmos_client_options.get( + "connection_policy", documents.ConnectionPolicy() + ) + + return CosmosClient( + url=self._config.cosmos_db_endpoint, + credential=cred, + consistency_level=self._config.cosmos_client_options.get( + "consistency_level", None + ), + **{ + "connection_policy": connection_policy, + "connection_verify": not connection_policy.DisableSSLVerification, + }, + ) + + raise ValueError( + storage_errors.InvalidConfiguration.format( + "Either Cosmos DB Credential or Auth Key is required." + ) ) def _sanitize(self, key: str) -> str: diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py index 596a10360..37ccd65cc 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py @@ -19,8 +19,7 @@ def __init__( container_throughput: int | None = None, key_suffix: str = "", compatibility_mode: bool = False, - url: str = "", - credential: AsyncTokenCredential | None = None, + credential: Union[AsyncTokenCredential, None] = None, **kwargs, ): """Create the Config object. @@ -36,7 +35,6 @@ def __init__( key characters. (e.g. not: '\\', '?', '/', '#', '*') :param compatibility_mode: True if keys should be truncated in order to support previous CosmosDb max key length of 255. - :param url: The URL to the CosmosDB resource. :param credential: The TokenCredential to use for authentication. :return CosmosDBConfig: """ @@ -60,8 +58,7 @@ def __init__( self.compatibility_mode: bool = compatibility_mode or kwargs.get( "compatibility_mode", False ) - self.url = url or kwargs.get("url", "") - self.credential: AsyncTokenCredential | None = credential + self.credential: Union[AsyncTokenCredential, None] = credential @staticmethod def validate_cosmos_db_config(config: "CosmosDBStorageConfig") -> None: diff --git a/tests/storage_cosmos/test_cosmos_db_storage.py b/tests/storage_cosmos/test_cosmos_db_storage.py index d71da51b2..95117885e 100644 --- a/tests/storage_cosmos/test_cosmos_db_storage.py +++ b/tests/storage_cosmos/test_cosmos_db_storage.py @@ -253,9 +253,9 @@ async def test_cosmos_db_from_azure_cred(self): load_dotenv() cred = DefaultAzureCredential() - url = os.environ.get("TEST_COSMOS_DB_ENDPOINT") + url = os.environ.get("TEST_COSMOS_DB_ENDPOINT", "") config = CosmosDBStorageConfig( - url=url, + cosmos_db_endpoint=url, credential=cred, database_id="test-db", container_id="bot-storage", From 71d32dce952a43e892fbafbed42ffaf99e02381a Mon Sep 17 00:00:00 2001 From: Kyle Rohn Date: Tue, 30 Jun 2026 14:17:28 -0700 Subject: [PATCH 02/12] raise error for url in kwargs --- .../storage/cosmos/cosmos_db_storage_config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py index 37ccd65cc..a8540d028 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py @@ -45,6 +45,12 @@ def __init__( self.cosmos_db_endpoint: str = cosmos_db_endpoint or kwargs.get( "cosmos_db_endpoint", "" ) + + if "url" in kwargs: + raise ValueError( + "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead." + ) + self.auth_key: str = auth_key or kwargs.get("auth_key", "") self.database_id: str = database_id or kwargs.get("database_id", "") self.container_id: str = container_id or kwargs.get("container_id", "") From ae8ceebcc45bf3904ec1c1791ff68ac9a2271559 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Tue, 30 Jun 2026 14:47:24 -0700 Subject: [PATCH 03/12] use specific errors, fix docstring specificity, remove `Union` in favor of `|` --- .../microsoft_agents/storage/cosmos/cosmos_db_storage.py | 4 ++-- .../storage/cosmos/cosmos_db_storage_config.py | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py index 5867e4f66..71b0a20ca 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py @@ -55,7 +55,7 @@ def _create_client(self) -> CosmosClient: if not self._config.cosmos_db_endpoint: raise ValueError( - storage_errors.InvalidConfiguration.format( + storage_errors.CosmosDbEndpointRequired.format( "Cosmos DB Endpoint is required." ) ) @@ -84,7 +84,7 @@ def _create_client(self) -> CosmosClient: ) raise ValueError( - storage_errors.InvalidConfiguration.format( + storage_errors.CosmosDbAuthKeyRequired.format( "Either Cosmos DB Credential or Auth Key is required." ) ) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py index a8540d028..1227c08cc 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py @@ -19,7 +19,7 @@ def __init__( container_throughput: int | None = None, key_suffix: str = "", compatibility_mode: bool = False, - credential: Union[AsyncTokenCredential, None] = None, + credential: AsyncTokenCredential | None = None, **kwargs, ): """Create the Config object. @@ -36,7 +36,7 @@ def __init__( :param compatibility_mode: True if keys should be truncated in order to support previous CosmosDb max key length of 255. :param credential: The TokenCredential to use for authentication. - :return CosmosDBConfig: + :return CosmosDBStorageConfig: """ config_file: str = kwargs.get("filename", "") if config_file: @@ -50,7 +50,7 @@ def __init__( raise ValueError( "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead." ) - + self.auth_key: str = auth_key or kwargs.get("auth_key", "") self.database_id: str = database_id or kwargs.get("database_id", "") self.container_id: str = container_id or kwargs.get("container_id", "") @@ -64,7 +64,7 @@ def __init__( self.compatibility_mode: bool = compatibility_mode or kwargs.get( "compatibility_mode", False ) - self.credential: Union[AsyncTokenCredential, None] = credential + self.credential: AsyncTokenCredential | None = credential @staticmethod def validate_cosmos_db_config(config: "CosmosDBStorageConfig") -> None: From 97f88510165c8c29f20cf1a5d5cabfad2fa9969e Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Tue, 30 Jun 2026 14:47:48 -0700 Subject: [PATCH 04/12] update unit tests --- tests/storage_cosmos/test_cosmos_db_storage.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/storage_cosmos/test_cosmos_db_storage.py b/tests/storage_cosmos/test_cosmos_db_storage.py index 95117885e..4dbb0dc4d 100644 --- a/tests/storage_cosmos/test_cosmos_db_storage.py +++ b/tests/storage_cosmos/test_cosmos_db_storage.py @@ -194,7 +194,6 @@ async def test_cosmos_db_storage_flow_existing_container_and_persistence( @pytest.mark.cosmos class TestCosmosDBStorage(QuickCRUDStorageTests): - def get_compat_mode(self): return False @@ -253,9 +252,9 @@ async def test_cosmos_db_from_azure_cred(self): load_dotenv() cred = DefaultAzureCredential() - url = os.environ.get("TEST_COSMOS_DB_ENDPOINT", "") + cosmos_db_endpoint = os.environ.get("TEST_COSMOS_DB_ENDPOINT", "") config = CosmosDBStorageConfig( - cosmos_db_endpoint=url, + cosmos_db_endpoint=cosmos_db_endpoint, credential=cred, database_id="test-db", container_id="bot-storage", @@ -284,7 +283,6 @@ async def test_cosmos_db_from_azure_cred(self): # @pytest.mark.skipif(not EMULATOR_RUNNING, reason="Needs the emulator to run.") @pytest.mark.cosmos class TestCosmosDBStorageInit: - def test_raises_error_when_suffix_provided_but_compat(self, config): config.auth_key = None config.compatibility_mode = True @@ -302,6 +300,17 @@ def test_raises_error_when_no_container_id_provided(self, config): with pytest.raises(ValueError): CosmosDBStorage(config) + def test_raises_error_when_no_endpoint_provided(self, config): + config.cosmos_db_endpoint = None + with pytest.raises(ValueError): + CosmosDBStorage(config) + + def test_raises_error_when_no_auth_key_or_cred_provided(self, config): + config.auth_key = None + config.credential = None + with pytest.raises(ValueError): + CosmosDBStorage(config) + @pytest.mark.asyncio @pytest.mark.parametrize("compat_mode", [True, False]) async def test_raises_error_different_partition_key(self, compat_mode): From 617851ae2f2a068f39bfbfec0584f58e8a9db7b4 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Tue, 30 Jun 2026 15:01:10 -0700 Subject: [PATCH 05/12] fix error representations --- .../storage/cosmos/cosmos_db_storage.py | 12 ++---------- .../storage/cosmos/errors/error_resources.py | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py index 71b0a20ca..f9e55c634 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage.py @@ -54,11 +54,7 @@ def __init__(self, config: CosmosDBStorageConfig): def _create_client(self) -> CosmosClient: if not self._config.cosmos_db_endpoint: - raise ValueError( - storage_errors.CosmosDbEndpointRequired.format( - "Cosmos DB Endpoint is required." - ) - ) + raise ValueError(str(storage_errors.CosmosDbEndpointRequired)) if self._config.credential or self._config.auth_key: cred = ( @@ -83,11 +79,7 @@ def _create_client(self) -> CosmosClient: }, ) - raise ValueError( - storage_errors.CosmosDbAuthKeyRequired.format( - "Either Cosmos DB Credential or Auth Key is required." - ) - ) + raise ValueError(str(storage_errors.CosmosDbAuthKeyRequired)) def _sanitize(self, key: str) -> str: return sanitize_key( diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/errors/error_resources.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/errors/error_resources.py index ddec9e90a..332c9bbeb 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/errors/error_resources.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/errors/error_resources.py @@ -28,7 +28,7 @@ class StorageErrorResources: ) CosmosDbAuthKeyRequired = ErrorMessage( - "CosmosDBStorage: auth_key is required.", + "CosmosDBStorage: auth_key or credential is required.", -61002, ) From 56eafe7df3ad28a18c7e9c9bf87a68601b26f62d Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Tue, 30 Jun 2026 15:04:38 -0700 Subject: [PATCH 06/12] Use standardized error message instance Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../storage/cosmos/cosmos_db_storage_config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py index 1227c08cc..19b4fee8d 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py @@ -48,7 +48,9 @@ def __init__( if "url" in kwargs: raise ValueError( - "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead." + storage_errors.InvalidConfiguration.format( + "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead." + ) ) self.auth_key: str = auth_key or kwargs.get("auth_key", "") From 65d952ea9489f166f0c6258dd88aba859e7f50ce Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Tue, 30 Jun 2026 15:13:53 -0700 Subject: [PATCH 07/12] More robust assertion for testing empty cosmos endpoint Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tests/storage_cosmos/test_cosmos_db_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/storage_cosmos/test_cosmos_db_storage.py b/tests/storage_cosmos/test_cosmos_db_storage.py index 4dbb0dc4d..0513ead98 100644 --- a/tests/storage_cosmos/test_cosmos_db_storage.py +++ b/tests/storage_cosmos/test_cosmos_db_storage.py @@ -302,7 +302,7 @@ def test_raises_error_when_no_container_id_provided(self, config): def test_raises_error_when_no_endpoint_provided(self, config): config.cosmos_db_endpoint = None - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="cosmos_db_endpoint is required"): CosmosDBStorage(config) def test_raises_error_when_no_auth_key_or_cred_provided(self, config): From bcc4356d1daa12f3439c12204d7766db68f5cd73 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Tue, 30 Jun 2026 15:14:59 -0700 Subject: [PATCH 08/12] More robust assertion for testing empty authorization Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tests/storage_cosmos/test_cosmos_db_storage.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/storage_cosmos/test_cosmos_db_storage.py b/tests/storage_cosmos/test_cosmos_db_storage.py index 0513ead98..e42df9406 100644 --- a/tests/storage_cosmos/test_cosmos_db_storage.py +++ b/tests/storage_cosmos/test_cosmos_db_storage.py @@ -308,7 +308,7 @@ def test_raises_error_when_no_endpoint_provided(self, config): def test_raises_error_when_no_auth_key_or_cred_provided(self, config): config.auth_key = None config.credential = None - with pytest.raises(ValueError): + with pytest.raises(ValueError, match="auth_key or credential is required"): CosmosDBStorage(config) @pytest.mark.asyncio From 35251a617be0089a8ffdc4df437ecdbd89ed63f2 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Wed, 1 Jul 2026 10:44:36 -0700 Subject: [PATCH 09/12] Specify ambiguous message Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../microsoft_agents/storage/cosmos/cosmos_db_storage_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py index 19b4fee8d..530e9668e 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py @@ -49,7 +49,7 @@ def __init__( if "url" in kwargs: raise ValueError( storage_errors.InvalidConfiguration.format( - "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead." + "The 'url' parameter is no longer supported. Please use 'cosmos_db_endpoint' instead." ) ) From edad8ccc964cdadc7ef3309737f2326d61304929 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Wed, 1 Jul 2026 11:02:06 -0700 Subject: [PATCH 10/12] change url error to dep warning --- .../storage/cosmos/cosmos_db_storage_config.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py index 530e9668e..b6e24600f 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py @@ -1,4 +1,5 @@ import json +import warnings from azure.core.credentials_async import AsyncTokenCredential from microsoft_agents.storage.cosmos.errors import storage_errors @@ -47,11 +48,11 @@ def __init__( ) if "url" in kwargs: - raise ValueError( - storage_errors.InvalidConfiguration.format( - "The 'url' parameter is no longer supported. Please use 'cosmos_db_endpoint' instead." - ) + warnings.warn( + "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead.", + DeprecationWarning, ) + self.cosmos_db_endpoint = kwargs.get("url", self.cosmos_db_endpoint) self.auth_key: str = auth_key or kwargs.get("auth_key", "") self.database_id: str = database_id or kwargs.get("database_id", "") From a996c26598ec9ce327c4fbf23e55f68081315e77 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Mon, 13 Jul 2026 11:44:37 -0700 Subject: [PATCH 11/12] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- .../storage/cosmos/cosmos_db_storage_config.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py index b6e24600f..4ac3b919a 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py @@ -51,8 +51,10 @@ def __init__( warnings.warn( "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead.", DeprecationWarning, + stacklevel=2, ) - self.cosmos_db_endpoint = kwargs.get("url", self.cosmos_db_endpoint) + if not self.cosmos_db_endpoint: + self.cosmos_db_endpoint = kwargs.get("url", "") self.auth_key: str = auth_key or kwargs.get("auth_key", "") self.database_id: str = database_id or kwargs.get("database_id", "") From c508cbb49c49cd3a70ad7e6c7685ab1bb77543c3 Mon Sep 17 00:00:00 2001 From: kylerohn-msft Date: Mon, 13 Jul 2026 11:49:44 -0700 Subject: [PATCH 12/12] use logging instead of warnings --- .../storage/cosmos/cosmos_db_storage_config.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py index 4ac3b919a..6fd9c0cbd 100644 --- a/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py +++ b/libraries/microsoft-agents-storage-cosmos/microsoft_agents/storage/cosmos/cosmos_db_storage_config.py @@ -1,11 +1,13 @@ import json -import warnings +import logging from azure.core.credentials_async import AsyncTokenCredential from microsoft_agents.storage.cosmos.errors import storage_errors from .key_ops import sanitize_key +logger = logging.getLogger(__name__) + class CosmosDBStorageConfig: """The class for partitioned CosmosDB configuration for the Azure Bot Framework.""" @@ -32,7 +34,7 @@ def __init__( :param cosmos_client_options: The options for the CosmosClient. Currently only supports connection_policy and consistency_level :param container_throughput: The throughput set when creating the Container. Defaults to 400. - :param key_suffix: The suffix to be added to every key. The keySuffix must contain only valid ComosDb + :param key_suffix: The suffix to be added to every key. The keySuffix must contain only valid CosmosDb key characters. (e.g. not: '\\', '?', '/', '#', '*') :param compatibility_mode: True if keys should be truncated in order to support previous CosmosDb max key length of 255. @@ -48,10 +50,8 @@ def __init__( ) if "url" in kwargs: - warnings.warn( - "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead.", - DeprecationWarning, - stacklevel=2, + logger.warning( + "The 'url' parameter is deprecated. Please use 'cosmos_db_endpoint' instead." ) if not self.cosmos_db_endpoint: self.cosmos_db_endpoint = kwargs.get("url", "")