Open TechWatching opened 5 years ago
Same issue here ...
Able to reproduce the error. Triaging the issue for further investigation
@ealsur , @brettsam , Is the below code the right syntax to use with cosmosDb. Can you kindly share your inputs here
public async Task Save([ServiceBusTrigger("myServiceBus", Connection = "MyServiceBusConnectionString")] Message message,
[CosmosDB(databaseName: "MyCosmosDb",
collectionName: "MyCollection",
ConnectionStringSetting = "MyCosmosDbConnectionString",
SqlQuery = "SELECT top 1 * FROM c where c.MyProperty = {UserProperties[\"MyProperty\"]}"
)] IEnumerable
I am not familiar with the binding expressions, from the Cosmos DB side, the binding should result in a string, but this error seems to be coming from the binding expression parsing, not particular to Cosmos DB.
Hi @ealsur , Thank you for your inputs. Can you tag the right folks who could help us here. Is there any particular repo this issue can be transferred to
@v-anvari the repo I believe is correct, but I wouldn't know who would be the owners of the binding mapping. From reading the code, I see that it happens here: https://github.com/Azure/azure-webjobs-sdk-extensions/blob/dev/src/WebJobs.Extensions.CosmosDB/CosmosDBSqlResolutionPolicy.cs
But this error does not happen there, this is a generic validation that says that the Binding Expression is incorrect, the error does not seem to come from the code in this repo, or at least I don't see anywhere where that particular error message is generated. @brettsam do you happen to know the source?
I have an Azure Function triggered by ServiceBus, with a CosmosDB input binding whose sqlQuery use a property of the ServiceBus message to retrieve a document. Unfortunately it does not work, I receive an exception when launching my Azure Function :
Microsoft.Azure.WebJobs.Host: Error indexing method 'SaveFunction'. Microsoft.Azure.WebJobs.Host: Invalid template 'SELECT top 1 * FROM c where c.MyProperty = {UserProperties["MyProperty"]}'. Invalid template expression 'UserProperties["MyProperty"].
Repro steps
Create an Azure Function triggered by ServiceBus with an CosmosDb input binding that uses in its SqlQuery a UserProperty of the ServiceBus Message (see sample code at the end).
Run the Azure Function
Expected behavior
The Azure Function should be indexed correctly, without error
Actual behavior
I receive this exception :
Microsoft.Azure.WebJobs.Host: Error indexing method 'SaveFunction'. Microsoft.Azure.WebJobs.Host: Invalid template 'SELECT top 1 * FROM c where c.MyProperty = {UserProperties["MyProperty"]}'. Invalid template expression 'UserProperties["MyProperty"].
Related information
The source code look like that