Search code examples
c#tfsdevopsbacklog

WorkItem Creation Transaction Rollback


Is there a way to implement a rollback mechanism when creating work items in C#? I want the work items to be created only after the program finishes running successfully. If an exception occurs, the creation should be rolled back. Like i've written a program that reads workitems from a TFS and creates a new workitem accordingly in DevOps. but since there are around 100'000 WorkItems, i wanted to implement this, but don't know how.

i know that i can do something similar when working with a database but i don't know if it's possible to do this in this case.


Solution

  • Is there a way to implement a rollback mechanism when creating work items in C#?

    I am afraid that the creation of work items cannot be rolled back.

    After your program executes to read and create work items, the created work items can only be deleted but not rolled back when an exception is caught. But in this case, the work item ID that has already been used still cannot be reused after permanently delete.

    Here is the API you can use to delete work items: Work Items - Delete

    DELETE https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?destroy={destroy}&api-version=7.1