Reputation: 6157
I have an Azure Search
that uses Azure Storage
as datasource. I'm trying to get the Search
to delete files from it's result whenever they are deleted in the Storage
, but somehow I can't seem to achieve it.
So far I've tried to setup a soft-delete policy on the Storage
to keep files for another 7 days, and a soft-delete policy on the Search
to check for the metadata column IsDeleted
and if true
delete the item from its results. Then using code I change the metadata and then delete the file as follows:
blob.Metadata["IsDeleted"] = "true";
blob.SetMetadataAsync().Wait();
blob.DeleteAsync().Wait();
Without the deleting it seems to work fine, but with it I guess the Search
can no longer access the metadata even if the file is still retained. I'm assuming something as simply as this is already thought out, but I can't seem to find it.
Upvotes: 1
Views: 1278
Reputation: 136196
Short answer is that you can't use soft delete blobs in Azure Search.
When a blob is soft deleted from storage, for all intents and purpose the blob is deleted. You can't perform any operation on the blob before undeleting it first. It is also not returned as part of regular blob listing process.
Because of this fact, when an indexer runs to fetch the list of blobs it does not find soft deleted blob. Only way to mark the blob deleted from search service indexer point of view is to keep the blob in storage and set the metadata property "IsDeleted" to "true" which you're doing.
Upvotes: 2