{"record":{"id":"9dbdd510d1588beb","repo":"microsoft/semantic-kernel","slug":"the-credential-parameter-is-required-for-authent-9dbdd5","errorCode":null,"errorMessage":"The 'credential' parameter is required for authentication.","messagePattern":"The 'credential' parameter is required for authentication\\.","errorType":"exception","errorClass":"VectorStoreInitializationException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/azure_cosmos_db.py","lineNumber":609,"sourceCode":"                key=key,\n                database_name=database_name,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as e:\n            raise VectorStoreInitializationException(\"Failed to validate Azure Cosmos DB NoSQL settings.\") from e\n\n        if cosmos_db_nosql_settings.database_name is None:\n            raise VectorStoreInitializationException(\"The name of the Azure Cosmos DB NoSQL database is missing.\")\n\n        if cosmos_client is None:\n            if cosmos_db_nosql_settings.key is not None:\n                cosmos_client = CosmosClient(\n                    str(cosmos_db_nosql_settings.url), credential=cosmos_db_nosql_settings.key.get_secret_value()\n                )\n            else:\n                if credential is None:\n                    raise VectorStoreInitializationException(\n                        \"The 'credential' parameter is required for authentication.\"\n                    )\n                cosmos_client = CosmosClient(str(cosmos_db_nosql_settings.url), credential=credential)\n\n        super().__init__(\n            cosmos_client=cosmos_client,\n            database_name=cosmos_db_nosql_settings.database_name,\n            cosmos_db_nosql_settings=cosmos_db_nosql_settings,\n            create_database=create_database,\n            **kwargs,\n        )\n\n    async def _does_database_exist(self) -> bool:\n        \"\"\"Checks if the database exists.\"\"\"\n        try:\n            await self.cosmos_client.get_database_client(self.database_name).read()\n            return True\n        except CosmosResourceNotFoundError:","sourceCodeStart":591,"sourceCodeEnd":627,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/azure_cosmos_db.py#L591-L627","documentation":"When constructing a CosmosClient without a key, the connector falls back to token-based authentication. If neither a key nor a credential object is available, it cannot authenticate and raises VectorStoreInitializationException. This is an auth-config guard at construction time.","triggerScenarios":"Raised in CosmosNoSqlBase.__init__ when cosmos_client is None, cosmos_db_nosql_settings.key is None, and the caller passed credential=None. Triggered when you rely on Entra ID but forget to supply an AsyncTokenCredential (e.g. DefaultAzureCredential).","commonSituations":"Forgetting to pass credential=DefaultAzureCredential() when not using a key. Assuming Managed Identity is picked up automatically without wiring the credential. Confusion between key-based and Entra ID auth paths.","solutions":["Pass a credential such as credential=DefaultAzureCredential() (from azure.identity.aio) when not using a key.","Or supply the account key via key= or the key env var.","Or pass a pre-configured cosmos_client that already has credentials resolved."],"exampleFix":"// before\nclient = CosmosNoSqlCollection(..., url=url)  # no key, no credential\n// after\nfrom azure.identity.aio import DefaultAzureCredential\nclient = CosmosNoSqlCollection(..., url=url, credential=DefaultAzureCredential())","handlingStrategy":"validation","validationCode":"if not key and not os.getenv(\"COSMOS_DB_NOSQL_KEY\") and credential is None:\n    raise ValueError(\"Either a key or a credential must be supplied for CosmosNoSql auth\")\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Standardize on DefaultAzureCredential for Entra ID flows in production.","Pass key explicitly only for local dev/test.","Document the key-vs-credential decision in your project README."],"tags":["azure-cosmos-db","vector-store","initialization","authentication","security"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}