Reputation: 523
I've implemented video upload from a Xamarin.Forms application to Azure blob storage using the Azure.Storage.Blobs SDK.
A requirement is that the upload can only happen while the application is active. The approach taken is to upload the video using blocks, so that I can handle partial upload and the resuming of the upload when the app sleeps/awakens - this part is implemented and working correctly.
I'm using BlockBlobClient.StageBlockAsync
where the documentation states "The StageBlockAsync operation creates a new block as part of a block blob's "staging area" to be eventually committed"
Now this approach is working very well for me and giving the desired results, however I can't seem to find any mention of whether an individual block gets expired if a commit operation hasn't been attempted.
The scenario: The application has 7 blocks to upload, 3 upload successfully then the application is exited - when the application resumes it should upload the remaining blocks and commit them.
If the application is not opened for some time, will the uploaded blocks expire?
Thanks
Upvotes: 1
Views: 1286
Reputation: 5257
One week, agree with Stopped Contributing answer, you can also find it looking at the code:
namespace Azure.Storage.Blobs.Specialized
public class BlockBlobClient : BlobBaseClient
has the answer in the summary
Summary: ... If you don’t commit any block to this blob, it and its uncommitted blocks will be discarded one week after the last successful block upload. All uncommitted blocks are also discarded when a new blob of the same name is created using a single step(rather than the two-step block upload-then-commit process).
In addition you can use the following (which can be helpful to check if any blocks have expired and gone missing)
BlockList blocks = await blockBlob.GetBlockListAsync();
Upvotes: 0
Reputation: 136196
Now this approach is working very well for me and giving the desired results, however I can't seem to find any mention of whether an individual block gets expired if a commit operation hasn't been attempted.
Individual blocks will get expired after 7 days if not committed. From the REST API documentation link
:
If you call Put Block on a blob that does not yet exist, a new block blob is created with a content length of 0. This blob is enumerated by the List Blobs operation if the include=uncommittedblobs option is specified. The block or blocks that you uploaded are not committed until you call Put Block List on the new blob. A blob created this way is maintained on the server for a week; if you have not added more blocks or committed blocks to the blob within that time period, then the blob is garbage collected.
Same is also mentioned here: https://learn.microsoft.com/en-us/dotnet/api/azure.storage.blobs.specialized.blockblobclient?view=azure-dotnet (last paragraph).
Upvotes: 3