{"record":{"id":"07486e6a699843ba","repo":"apache/seatunnel","slug":"failed-to-open-azurecosmosdb-source-reader-for-dat","errorCode":null,"errorMessage":"Failed to open AzureCosmosDB source reader for database [%s], container [%s]","messagePattern":"Failed to open AzureCosmosDB source reader for database \\[(.+?)\\], container \\[(.+?)\\]","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-azurecosmosdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/azurecosmosdb/source/AzureCosmosDBSourceReader.java","lineNumber":81,"sourceCode":"        this.context = context;\n        this.config = config;\n        this.deserializer = new CosmosItemDeserializer(rowType);\n    }\n\n    @Override\n    public void open() {\n        try {\n            this.client =\n                    new CosmosClientBuilder()\n                            .endpoint(config.getResolvedEndpoint())\n                            .key(config.getResolvedKey())\n                            .endpointDiscoveryEnabled(false)\n                            .gatewayMode()\n                            .buildClient();\n            this.container =\n                    client.getDatabase(config.getDatabase()).getContainer(config.getContainer());\n        } catch (Exception e) {\n            throw new IllegalStateException(\n                    String.format(\n                            \"Failed to open AzureCosmosDB source reader for database [%s], container [%s]\",\n                            config.getDatabase(), config.getContainer()),\n                    e);\n        }\n    }\n\n    @Override\n    public void close() {\n        if (client != null) {\n            client.close();\n        }\n    }\n\n    @Override\n    public void pollNext(Collector<SeaTunnelRow> output) {\n        AzureCosmosDBSourceSplit activeSplit;\n        String continuationToken;","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-azurecosmosdb/src/main/java/org/apache/seatunnel/connectors/seatunnel/azurecosmosdb/source/AzureCosmosDBSourceReader.java#L63-L99","documentation":"AzureCosmosDBSourceReader.open() builds the CosmosAsyncClient and fetches the target database/container handle. Any failure during client creation or the database/container lookup is wrapped into an IllegalStateException naming the database and container, with the underlying cause attached.","triggerScenarios":"Calling open() when the SDK client cannot be built (bad endpoint/key, network unreachable) or `client.getDatabase(db).getContainer(container)` fails because the account is unreachable, credentials are wrong, or the database/container does not exist.","commonSituations":"Typo in database or container name; key/uri mismatched for the account; no network egress from the cluster to *.documents.azure.com; firewall/VNet rules blocking the worker; container deleted between planning and read.","solutions":["Check the wrapped cause (`e`) for the real SDK error (401 auth, 404 NotFound, DNS/connect timeout)","Verify database and container names match those in the Azure portal (case-sensitive)","Confirm `uri` points to the correct account endpoint and `key` is that account's key","Test network reachability to `<account>.documents.azure.com:443` from worker nodes and check firewall rules"],"exampleFix":"// before (config names don't match Azure)\nuri = \"https://myaccount.documents.azure.com:443/\"\ndatabase = \"Shop\"   // actual DB is \"shop\"\n// after\nuri = \"https://myaccount.documents.azure.com:443/\"\ndatabase = \"shop\"\ncontainer = \"orders\"","handlingStrategy":"try-catch","validationCode":"// before opening: verify names exist via a lightweight client call\nclient.getDatabase(dbName).read()\n    .doOnSuccess(db -> System.out.println(\"DB ok: \" + db.getId()))\n    .block();","typeGuard":null,"tryCatchPattern":"try {\n    reader.open();\n} catch (IllegalStateException e) {\n    log.error(\"Cosmos open failed for db/container; cause={}\", e.getCause(), e);\n    // check auth (401) vs not-found (404) vs network before retrying\n}","preventionTips":["Verify database/container names in the Azure portal before configuring the job","Confirm worker nodes can reach <account>.documents.azure.com:443","Check Azure Cosmos DB firewall/VNet rules allow the cluster egress IPs"],"tags":["azure-cosmosdb","network","resource-not-found","initialization"],"backgroundTag":"resource-not-found","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}