2

I have a function in a c# class library project that is triggered by a change in a cosmos database:

[FunctionName("SomeFunction")]
public async Task Run(
    [CosmosDBTrigger(
        databaseName: "%CosmosDatabaseName%",
        collectionName: "%CosmosCollectionName%",
        ConnectionStringSetting = "CosmosConnectionString",
        CreateLeaseCollectionIfNotExists = true,
        LeaseCollectionName = "_leases",
        FeedPollDelay = 20000,
        MaxItemsPerInvocation = 20,
        LeaseCollectionPrefix = "Leases_")]
    IReadOnlyList<Document> changedDocuments,
    ILogger log,
    [Blob("%BlobContainerName%", Connection = "BlobConn")]
    CloudBlobContainer destinationContainer)
{
    ...
}

I was able to figure out how to pull some of the values from settings.json (databaseName, collectionName, etc...), but not FeedPollDelay or MaxItemsPerInvocation (due to them being of type int).

I am aware that there is a function.json that is generated, but I have no clue on how to modify it (and MSDN seems to hint that you shouldn't do that).

  • If you check this [configuration properties](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-cosmosdb-v2-trigger?tabs=csharp#configuration) that you set in the function.json file and the CosmosDBTrigger attribute, you will find that `FeedPollDelay` is the time (in milliseconds) after which CosmosDBTrigger will poll for changes. And we just need to specify it in our _function.json_. Could you elaborate why you want to configure them and what is the problem you facing so that I can help. – SauravDas-MT Oct 28 '21 at 11:33
  • If you doesn't want to process multiple transitions then you must put a logic in your function to avoid multiple transition. – SauravDas-MT Oct 28 '21 at 11:35
  • We want to configure them so that we could deploy a "faster" version (e.g.: polls every 1 sec) of this function into our test environment. And a "slower" (e.g. polls every 60 seconds) in production. – user1354455 Oct 29 '21 at 12:15
  • Can please provide a sample code you are using for fetching/pulling the other properties like databaseName, connectionName etc. and what error you are getting when you are trying to fetch/pull FeedPollDelay so that I can repro and give you a satisfying answer. – SauravDas-MT Nov 01 '21 at 11:08
  • Till now I didn't found any document that explains how to configure integer (non-string) in any trigger for azure functions. The function app settings values can also be read in your code as environment variables. But it's not recommended for the integer values. **The ways you can achieve your desired result by manually setting/specifying the values in different environment.** If this helps please tell me so that I can post it as answer. – SauravDas-MT Nov 02 '21 at 12:29

0 Answers0