I'm creating an Azure Function that downloads the XML of a given URL and stores the document in Cosmos DB at predefined times. Currently I develop the application locally in VSC with Java and also using the Cosmos DB Emulator. Within my code I instantiate a CosmosClient-object with the following code:
private static CosmosClient cosmosClient = new CosmosClientBuilder().endpoint("https://localhost:8081")
.key("C2y6yDjf5/R ob0N8A7Cgv30VRDJIWEHLM 4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==").consistencyLevel(ConsistencyLevel.EVENTUAL).buildClient();
Whenever I run my code the programm executs but after at the end of the buildClient() method a huge amount of threads are created leading to the following error message:
Terminal error message:
I took the URL and the key from the web surface of the emulator so where is my mistake? Do I have to provide additional credentials.
SOLVED: I made the mistake, that I added the Azure Cosmos Emulator certificate to the wrong java keystore as the Azure guide mentioned. My system variables only showed at my user version of the JVM, while I loaded the certificate to the global JVM copy, therefore resulting to a signature failure. A complete solution was provided in this post.
CodePudding user response:
From within Java azure function, connecting to local Azure CosmosDB Emulator fails in authentication step due to the CA certificate not present in the certificate trust store. By importing the CA cert, and setting the properties javax.net.ssl.trustStore
and javax.net.ssl.trustStoreType
the authentication step will go through. Details are in this SO answer and here.