Search code examples
azure-functionsazure-cosmosdb

Azure Function CosmosDBOutput in Isolated mode requires specifying the resource id?


I just migrated my Azure Function from .NET 6.0 to .NET 8.0, and while doing that - I also moved from the inline process mode to the new isolated mode.

The Function uses the CosmosDBOutput attribute so that values returned from it are stored in a container in my CosmosDB.

In the .NET 6.0 version I didn't have to specify the id of the resource, and it was automatically added by Cosmos (or the SDK?) using a GUID value.

However, in the new version I have to specify the id field, or else I get a (quite elusive) error message, stating that One of the specified inputs is invalid

Is there a way to not specify the id field of a new resource when using the CosmosDBOutput attribute?


Solution

  • It sounds like you are migrating from the older Extension version (3.x) to the new Extension version (4.x).

    This is detailed in the Migration guide.

    Item ID is no longer auto populated in the Extension. Therefore, the Item ID must specifically include a generated ID for cases where you were using the Output Binding to create items. To maintain the same behavior as the previous version, you can assign a random GUID as ID property.