You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On Node.js/TS/pm v4 - I have a CosmosDB trigger for tableA, then I want to process each doc, and insert into table B. I'm using extraOutputs because it is more obvious to me. Is there anything wrong with it?
Incoming doc has blob storage URL of a JSON object with mulitple items, I want each item to be insert into a different table. So this function turns 1 doc in tableA into many docs in tableB. Is there a better way to do this?
import{app,InvocationContext,output}from"@azure/functions";import{ProcessingDocument}from"../models";import{getJsonFromBlob}from"../azure-blob-storage";constsendToCosmosDb=output.cosmosDB({databaseName: 'github_history',containerName: 'issues',connection: 'AZURE_COSMOSDB_CONNECTION_STRING',createIfNotExists: false,});exportasyncfunctionlistenToDatabase(documents: unknown[],context: InvocationContext): Promise<void>{try{context.log(`Cosmos DB function processed ${documents.length} documents`);for(constdocofdocuments){constdocToProcess=docasProcessingDocument;// filename like `20240511_my_daily_issues_and_prs_1.json`// which has a format of `YYYYMMDD_{name}_{numDays}.json`// regex to extract the date and name and number of daysconstregex=/^(\d{8})_(.+)_(\d+)\.json$/;constmatch=docToProcess.name.match(regex);// extract the date and name and number of daysconstdate=match[1];constname=match[2];constnumDays=parseInt(match[3]);// Read DB doccontext.log(`Processing document with date ${date}, name ${name}, and numDays ${numDays}`);// Read blobconstdata=awaitgetJsonFromBlob(docToProcess.url,process.env.AZURE_STORAGE_CONNECTION_STRING,context.log);// Get the inner docs to send to a different DB tableconstinnerDocs=data?.results.itemsfor(constinnerDocofinnerDocs){context.extraOutputs.set(sendToCosmosDb,{type: name,
...innerDoc});}}}catch(error){context.log(`listenToDatabase - Error processing documents: ${error}`);}}app.cosmosDB('listen-to-database',{connectionStringSetting: 'AZURE_COSMOSDB_CONNECTION_STRING',databaseName: 'github_history',collectionName: 'data_processing',createLeaseCollectionIfNotExists: true,extraOutputs: [sendToCosmosDb],handler: listenToDatabase});
Error is : [2024-05-12T22:05:01.897Z] The 'listen-to-database' function is in error: Unable to configure binding 'cosmosDBTrigger026ae58797' of type 'cosmosDBTrigger'. This may indicate invalid function.json properties. Can't figure out which ctor to call.
The text was updated successfully, but these errors were encountered:
On Node.js/TS/pm v4 - I have a CosmosDB trigger for tableA, then I want to process each doc, and insert into table B. I'm using extraOutputs because it is more obvious to me. Is there anything wrong with it?
Incoming doc has blob storage URL of a JSON object with mulitple items, I want each item to be insert into a different table. So this function turns 1 doc in tableA into many docs in tableB. Is there a better way to do this?
Error is : [2024-05-12T22:05:01.897Z] The 'listen-to-database' function is in error: Unable to configure binding 'cosmosDBTrigger026ae58797' of type 'cosmosDBTrigger'. This may indicate invalid function.json properties. Can't figure out which ctor to call.
The text was updated successfully, but these errors were encountered: