I'm attempting to run the @azure/cosmos samples inside a node.js Azure Function. When it connects to the database it throws this error
" Executed 'Functions.store' (Failed, Id=a6df6cfb-ae78-4a0b-ae83-5d51efa9fc18) [10/7/2018 9:04:18 PM] System.Private.CoreLib: Exception while executing function: Functions.store. Microsoft.Azure.WebJobs.Host: Unable to resolve the value for property 'CosmosDBAttribute.ConnectionStringSetting'. Make sure the setting exists and has a valid value.
It fails at await client.databases.createIfNotExists
Anyone get @azure/cosmos to connect inside the index.js of an azure function?
Thanks, Donnie
const client = new CosmosClient({
endpoint: endpoint,
auth: { masterKey: masterKey }
});
async function init() {
const database = await client.databases.createIfNotExists({
id: databaseId
});
const container = await database.containers.createIfNotExists({
id: containerId
});
return container;
}
edited: added connection info
const connection = {
endpoint: "https://pdf-documents.documents.azure.com:443/",
primaryKey:
"Gub9FZeIMXwz6Lakn..."
};
const cosmos = require("@azure/cosmos");
const CosmosClient = cosmos.CosmosClient;
const endpoint = connection.endpoint;
const masterKey = connection.primaryKey;
const databaseId = "pdfDocuments";
const containerId = "pdfdocuments";
const client = new CosmosClient({
endpoint: endpoint,
auth: { masterKey: masterKey }
});
endpoint
value look like? – Nick Chapsas