microsoft/semantic-kernel · error · VectorStoreOperationException

Failed to get container proxy for '{container_name}'.

Error message

Failed to get container proxy for '{container_name}'.

What it means

_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).

Source

Thrown at python/semantic_kernel/connectors/azure_cosmos_db.py:652

    async def _get_database_proxy(self, **kwargs) -> DatabaseProxy:
        """Gets the database proxy."""
        try:
            if await self._does_database_exist():
                return self.cosmos_client.get_database_client(self.database_name)

            if self.create_database:
                return await self.cosmos_client.create_database(self.database_name, **kwargs)
            raise VectorStoreOperationException(f"Database '{self.database_name}' does not exist.")
        except Exception as e:
            raise VectorStoreOperationException(f"Failed to get database proxy for '{id}'.") from e

    async def _get_container_proxy(self, container_name: str, **kwargs) -> ContainerProxy:
        """Gets the container proxy."""
        try:
            database_proxy = await self._get_database_proxy(**kwargs)
            return database_proxy.get_container_client(container_name)
        except Exception as e:
            raise VectorStoreOperationException(f"Failed to get container proxy for '{container_name}'.") from e


# region: NoSQL Collection


@release_candidate
class CosmosNoSqlCollection(
    CosmosNoSqlBase,
    VectorStoreCollection[TNoSQLKey, TModel],
    VectorSearch[TNoSQLKey, TModel],
    Generic[TNoSQLKey, TModel],
):
    """An Azure Cosmos DB NoSQL collection stores documents in a Azure Cosmos DB NoSQL account."""

    partition_key: PartitionKey
    supported_key_types: ClassVar[set[str] | None] = {"str", "CosmosNoSqlCompositeKey"}
    supported_search_types: ClassVar[set[SearchType]] = {SearchType.VECTOR, SearchType.KEYWORD_HYBRID}

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Call await collection.create() to provision the container before first use.
  2. Ensure the database exists (see errors 1252/1253) and the container_name is correct.
  3. Inspect exc.__cause__ for the underlying Azure SDK error and address it (auth, network, RU).
Defensive patterns

Strategy: try-catch

Validate before calling

async def ensure_container(collection):
    if not await collection.does_container_exist():
        await collection.create()

Try / catch

try:
    await collection.upsert(record)
except VectorStoreOperationException as e:
    if 'container' in str(e).lower():
        await collection.create()
        await collection.upsert(record)

Prevention

When it happens

Trigger: 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.

Common situations: Accessing a collection before calling collection.create(). Container name typo. Database not provisioned. Throttling or auth errors during proxy resolution.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/f1810bc95df551cd. Report an issue: GitHub.