{"record":{"id":"20c293c9298781c4","repo":"microsoft/semantic-kernel","slug":"database-self-database-name-does-not-exist","errorCode":null,"errorMessage":"Database '{self.database_name}' does not exist.","messagePattern":"Database '(.+?)' does not exist\\.","errorType":"exception","errorClass":"VectorStoreOperationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":642,"sourceCode":"        try:\n            await self.cosmos_client.get_database_client(self.database_name).read()\n            return True\n        except CosmosResourceNotFoundError:\n            return False\n        except Exception as e:\n            raise VectorStoreOperationException(\n                f\"Failed to check if database '{self.database_name}' exists, with message {e}\"\n            ) from e\n\n    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,","sourceCodeStart":624,"sourceCodeEnd":660,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L624-L660","documentation":"When the database does not exist and create_database is False (the default), _get_database_proxy refuses to auto-create it and raises VectorStoreInitializationException. This is a deliberate guard: the store will not silently provision a database unless told to.","triggerScenarios":"Raised in _get_database_proxy when _does_database_exist() returns False and self.create_database is falsy. Triggered the first time you access the store/collection against a database name that was never provisioned, with create_database not set.","commonSituations":"New deployment pointing at a fresh Cosmos account where the database hasn't been created. Typo in database_name. Migrating environments (dev -> prod) without provisioning. Forgetting to pass create_database=True during setup.","solutions":["Provision the database in the Azure portal/CLI/SDK before running.","Or construct the store with create_database=True to auto-create it.","Verify database_name spelling against what exists in the account."],"exampleFix":"// before\nstore = CosmosNoSqlStore(url=url, key=key, database_name=\"mydb\")\n// after\nstore = CosmosNoSqlStore(url=url, key=key, database_name=\"mydb\", create_database=True)","handlingStrategy":"validation","validationCode":"async def ensure_database(store):\n    if not await store._does_database_exist():\n        if not store.create_database:\n            raise RuntimeError(f\"Database '{store.database_name}' missing; pass create_database=True or provision it\")\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set create_database=True in dev/bootstrap scripts.","Provision databases via IaC (Bicep/Terraform) in production.","Document that create_database defaults to False to avoid silent provisioning."],"tags":["azure-cosmos-db","vector-store","initialization","configuration","provisioning"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}