Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added DeleteStateOnClear option to AzureStorage persistence provider. #9393

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dbinky
Copy link

@dbinky dbinky commented Mar 18, 2025

Added DeleteStateOnClear option to AzureStorage persistence provider.

  • Added a boolean option to AzureBlobStorageOptions.cs for DeleteStateOnClear that defaults to true (which is the current, non-optional behavior)
  • Added a check for the option in AzureBlobStorage.cs, allowing users to preserve cleared state blobs if desired
  • Brings the AzureBlobStorage provider into conformance with the CosmosGrainStorage
Microsoft Reviewers: Open in CodeFlow

@dbinky
Copy link
Author

dbinky commented Mar 18, 2025

@dotnet-policy-service agree

await DoOptimisticUpdate(() => blob.DeleteIfExistsAsync(DeleteSnapshotsOption.None, conditions: conditions),
if (options.DeleteStateOnClear)
{
await DoOptimisticUpdate(() => blob.DeleteIfExistsAsync(DeleteSnapshotsOption.None, conditions: conditions),
Copy link
Member

@ReubenBond ReubenBond Mar 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If DeleteStateOnClear is false, is ClearStateAsync a no-op? I expect that it would write an empty blob if it's false.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's true. I could see this as useful in a few scenarios:
1 - It brings it into greater conformance with the Cosmos provider, which does have this option.
2 - I can envision some scenarios where it would be desirable to have the state blanked out and then saved. For example, if you're doing a synapse integration for analytics, just deleting the document from storage would not necessarily delete it from the synapse datalake, but if you wanted that data disincluded from your set, then saving and subsquently syncing a blank document would ensure that.
3 - There may be scenarios when you may not want to preserve the data of a document, but do want to have a record of used keys, which this would also do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants