{"record":{"id":"f1810bc95df551cd","repo":"microsoft/semantic-kernel","slug":"failed-to-get-container-proxy-for-container-name","errorCode":null,"errorMessage":"Failed to get container proxy for '{container_name}'.","messagePattern":"Failed to get container proxy for '(.+?)'\\.","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":652,"sourceCode":"    async def _get_database_proxy(self, **kwargs) -> DatabaseProxy:\n        \"\"\"Gets the database proxy.\"\"\"\n        try:\n            if await self._does_database_exist():\n                return self.cosmos_client.get_database_client(self.database_name)\n\n            if self.create_database:\n                return await self.cosmos_client.create_database(self.database_name, **kwargs)\n            raise VectorStoreOperationException(f\"Database '{self.database_name}' does not exist.\")\n        except Exception as e:\n            raise VectorStoreOperationException(f\"Failed to get database proxy for '{id}'.\") from e\n\n    async def _get_container_proxy(self, container_name: str, **kwargs) -> ContainerProxy:\n        \"\"\"Gets the container proxy.\"\"\"\n        try:\n            database_proxy = await self._get_database_proxy(**kwargs)\n            return database_proxy.get_container_client(container_name)\n        except Exception as e:\n            raise VectorStoreOperationException(f\"Failed to get container proxy for '{container_name}'.\") from e\n\n\n# region: NoSQL Collection\n\n\n@release_candidate\nclass CosmosNoSqlCollection(\n    CosmosNoSqlBase,\n    VectorStoreCollection[TNoSQLKey, TModel],\n    VectorSearch[TNoSQLKey, TModel],\n    Generic[TNoSQLKey, TModel],\n):\n    \"\"\"An Azure Cosmos DB NoSQL collection stores documents in a Azure Cosmos DB NoSQL account.\"\"\"\n\n    partition_key: PartitionKey\n    supported_key_types: ClassVar[set[str] | None] = {\"str\", \"CosmosNoSqlCompositeKey\"}\n    supported_search_types: ClassVar[set[SearchType]] = {SearchType.VECTOR, SearchType.KEYWORD_HYBRID}\n","sourceCodeStart":634,"sourceCodeEnd":670,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L634-L670","documentation":"_get_container_proxy obtains the database proxy then asks it for a container client. If anything throws during that chain (database missing, container missing, transport error), it's wrapped as VectorStoreOperationException naming the container. This runs before every container operation (upsert/get/delete/search).","triggerScenarios":"Raised in _get_container_proxy when either _get_database_proxy or database_proxy.get_container_client raises. Triggered when the container hasn't been created, the database doesn't exist, or a transport/auth error occurs while resolving the container proxy.","commonSituations":"Accessing a collection before calling collection.create(). Container name typo. Database not provisioned. Throttling or auth errors during proxy resolution.","solutions":["Call await collection.create() to provision the container before first use.","Ensure the database exists (see errors 1252/1253) and the container_name is correct.","Inspect exc.__cause__ for the underlying Azure SDK error and address it (auth, network, RU)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"async def ensure_container(collection):\n    if not await collection.does_container_exist():\n        await collection.create()\n","typeGuard":null,"tryCatchPattern":"try:\n    await collection.upsert(record)\nexcept VectorStoreOperationException as e:\n    if 'container' in str(e).lower():\n        await collection.create()\n        await collection.upsert(record)\n","preventionTips":["Call await collection.create() during deployment/bootstrap.","Verify container_name spelling against the database.","Add a readiness check before serving traffic."],"tags":["azure-cosmos-db","vector-store","runtime","provisioning","network"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}