Skip to content

CosmosDB lease container appears inoperable #175

@pzybe

Description

@pzybe

In my code I have the following Cosmosdb change-feed function:

                    .CosmosDb("cosmosDbConnection", cosmos => cosmos
                        .ChangeFeedFunction<UpdatePerspectiveGroupJob>(
                            "[scrubbed]",
                            "[scrubbed]",
                            leaseDatabaseName: "[scrubbed]",
                            createLeaseCollectionIfNotExists: true,
                            convertToPascalCase: true)));

providing both the leaseDatabaseName as well as the createLeastCollectionIfNotExists to ensure that the leases collection is created if it is not already there. However with these parameters specified I encounter this error:

[2021-07-27T17:26:41.687Z] The listener for function 'CosmosFnUpdatePerspectiveGroupJob' was unable to start. Microsoft.Azure.WebJobs.Extensions.CosmosDB: Either the source collection '[scrubbed]' (in database '[scrubbed]')  or the lease collection 'leases' (in database '[scrubbed]) does not exist. Both collections must exist before the listener starts. To automatically create the lease collection, set 'CreateLeaseCollectionIfNotExists' to 'true'. Microsoft.Azure.DocumentDB.Core: Message: {"Errors":["Resource Not Found. Learn more: https:\/\/aka.ms\/cosmosdb-tsg-not-found"]}

If I manually create the leases collection in my database all is well, but it looks like passing these parameters doesn't mean that function monkey will attempt to create the leases collection itself when building.
(sorry for the scrubbing, it's for a client with a well-known name. I checked and validated that both the database and containers do exist and are correctly named.)

As a side note: I don't intend for this function to need leases as no other function would be triggered by a change to cosmos, but even without this information provided to the change-feed function it still coughs. I referred to the following documentation to create the function https://functionmonkey.azurefromthetrenches.com/guides/cosmos/changeFeed.html which didn't mention anything about utilizing leases.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions