vscode-azurefunctions
vscode-azurefunctions copied to clipboard
Adding CosmosDB Output binding through the wizard creates invalid json
Version of VS Code - 1.67.2 Your operating system - Windows 11 Version of the relevant VS Code extension - Azure Functions v1.7.2 Reproducible steps (1... 2... 3...) that cause the issue
-
create a function project
-
add a blob storage trigger
-
add a cosmosdb output binding
- follow the prompts but leave
partitionkey
andcollectionThrouthput
as 'undefined'
- follow the prompts but leave
-
try and run the function locally with F5
What you expected to see, versus what you actually saw You get this error in the terminal:
-
If instead of running locally you deploy it to Azure, the function just doesn't trigger and I couldn't find errors anywhere to explain why
function.json file after adding the CosmosDB binding through the wizard:
{
"bindings": [
{
"name": "InputBlob",
"type": "blobTrigger",
"direction": "in",
"path": "source2/{name}",
"connection": "storagefundemo7_STORAGE"
},
{
"type": "cosmosDB",
"direction": "out",
"name": "outputDocument",
"databaseName": "grillenDb",
"collectionName": "data",
"createIfNotExists": false,
"connectionStringSetting": "cosmosdbfunctiondemo_DOCUMENTDB",
"partitionKey": "undefined",
"collectionThroughput": "undefined"
}
]
}
To fix the issue I had to remove these two keys (and the preceding comma) and redeploy the function to Azure.
"partitionKey": "undefined",
"collectionThroughput": "undefined"
When writing the json file, we shouldn't write properties with values of "undefined".
Thank you @motm32 I will test it out soon! 😄