Azure Reversal Release Pipeline Example
DataStar components encapsulate data and their related entities as scriptable units. When a deployment runs, the CLI can capture the pre-change state and build reversal scripts that undo the change. This page shows how to wire that into an Azure DevOps reversal pipeline.
Two storage options are available for the reversal scripts:
- Audit tables. DataStar's audit history holds the reversal scripts alongside the deployment log. Extract them on demand and run them.
- Package repository. The deployment generates a NuGet or zip package per work item and pushes it to an artefact feed.
This example uses the audit-tables option. For the package-repository flow, see the Octopus Apply Reversal pipeline.
Step 1. Add DataStar.Tools as a dependency
Publish the latest DataStar.Tools to the artefact feed and reference it from the pipeline so it's downloaded to the agent. This is the only dependency: the scripts to run come from the audit tables, not from a build artefact.
Step 2. Extract the reversal scripts
Add a command-line step that runs DataStar.Tools in reversal mode:
DataStar.Tools.exe -db "Microsoft" -en "DEV" \
-cs "User ID=$(DatabaseUser);Password=$(DatabasePassword);Data Source=$(DataSource);Database=$(Database)" \
-ae -ah "ADS_DEPLOYMENT_HISTORY" -ar "ADS_DEPLOYMENT_REVERSAL" -as "ADS_DEPLOYMENT_SUMMARY" \
-wi "$(WorkItem)" -cn "reversal" -od "$(System.ArtifactsDirectory)\Reversal"
The -wi flag selects the latest reversal package for the given work item. To target a specific deployment instead, use -id with the audit history record id.
The step writes reversal.json into the output directory with metadata for the next step:
{ "WorkItem": "33", "VersionNumber": 1, "AuditHistoryId": 12, "ArtifactName": "33-001" }
Step 3. Load the reversal metadata
Run the Set Json Parameters task against reversal.json to load WorkItem, VersionNumber, AuditHistoryId, and ArtifactName as pipeline variables.
Step 4. Run the reversal scripts
Add a second command-line step that executes the extracted scripts:
DataStar.Tools.exe -db "Microsoft" -en "DEV" \
-cs "User ID=$(DatabaseUser);Password=$(DatabasePassword);Data Source=$(DataSource);Database=$(Database)" \
-ae -ah "ADS_DEPLOYMENT_HISTORY" -ar "ADS_DEPLOYMENT_REVERSAL" -as "ADS_DEPLOYMENT_SUMMARY" \
-wi "$(WorkItem)" -vn "$(VersionNumber)" \
-wd "$(System.ArtifactsDirectory)\Reversal" -lf "output.txt" -ri "$(AuditHistoryId)"
-ri "$(AuditHistoryId)" links the reversal back to the original audit entry, so the history table shows which deployment the reversal cancels.
Step 5. Optional follow-up
Add further steps as required: update the work-item history, tag the build, notify a channel.
Client setup
For how reversal works in the DataStar client and the audit tables it depends on, see the Deployment History tab.