Azure function is not working after upgrading WebJobs.Extensions.CosmosDB and WebJobs.Extensions to the latest versions

lakshmi 816 Reputation points
2022-12-29T06:20:17.167+00:00

Based on the below reference document we have done the changes for the latest version of Cosmos DB extension.

https://learn.microsoft.com/en-us/azure/cosmos-db/nosql/migrate-dotnet-v3?tabs=dotnet-v3#major-name-changes-from-v2-sdk-to-v3-sdk

But still we are seeing error for the below cases,

=> In that article it also mentioned that "Document is renamed to Item" , I tried the same and it was showing error.

=>Table attribute also didnt worked saying "Could not found , are you missing some directive or assembly reference". Based on the below links, installed "Microsoft.Azure.WebJobs.Extensions.Tables" and the error in Table attribute has removed.

https://learn.microsoft.com/en-us/answers/questions/607702/microsoftazurewebjobsextensionsstorage-500-and-tab.html

https://github.com/Azure/azure-sdk-for-net/issues/25342

=> In Document client we had "DeleteDocumentAsync" for deleting the document . In Cosmos client , should we need to use the below method for document deletion,

274686-273190-image.png

Also we have removed the deprecated package " Microsoft.Azure.Cosmos.Table" and added " Azure.Data.Tables" .

In the below link , it has mentioned about TableClient which can be used in same place of Document client

https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.Tables/1.0.0

Can you please help to confirm which client needs to be used when using " Azure.Data.Tables" and "Microsoft.Azure.WebJobs.Extensions.Tables" packages

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,936 questions
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,441 Reputation points Moderator
    2023-01-05T16:18:32.383+00:00

    @lakshmi Thank you for sharing the code snippet. Based on your reference on Azure Cosmos DB .NET SDK v3, I assume you are using Microsoft.Azure.WebJobs.Extensions.CosmosDB with version 4.0.0 (which implements referenced SDK #717).

    As described in docs, there is no direct replacement for Document type and the recommendation is to use C# type instead of generic types. There are lot of samples about Usage in the SDK repo reference and ItemsManagement sample has all operations such as read items, create item, delete item, etc. that you might find it helpful (the example used SalesOrder type).

    276623-image.png

    The below description refers to the naming convention and will pass on the feedback to our doc's team since this might cause small confusion.

    Document is renamed to Item

    Also, want to let you know that Microsoft.Azure.WebJobs.Extensions.CosmosDB extension uses Microsoft.Azure.Cosmos library (refer NuGet) whereas Microsoft.Azure.WebJobs.Extensions.Tables extension uses new library Azure.Data.Tables (refer NuGet). I see there is another thread being discussed about this with Cosmos experts and feel free to post there for any specific questions about Cosmos library (refer Guidance)

    I hope this answers your question and feel free to add a comment if you have any other questions. We would be happy to assist you. Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.