protected override async Task DeleteAsync(SnapshotMetadata metadata) { var blobClient = Container.GetBlobClient(metadata.ToSnapshotBlobId()); using var cts = new CancellationTokenSource(_settings.RequestTimeout); await blobClient.DeleteIfExistsAsync(cancellationToken : cts.Token); }
protected override async Task SaveAsync(SnapshotMetadata metadata, object snapshot) { var blob = Container.GetBlockBlobReference(metadata.ToSnapshotBlobId()); var snapshotData = _serialization.SnapshotToBytes(new Serialization.Snapshot(snapshot)); using (var cts = new CancellationTokenSource(_settings.RequestTimeout)) { blob.Metadata.Add(TimeStampMetaDataKey, metadata.Timestamp.Ticks.ToString()); /* * N.B. No need to convert the key into the Journal format we use here. * The blobs themselves don't have their sort order affected by * the presence of this metadata, so we should just save the SeqNo * in a format that can be easily deserialized later. */ blob.Metadata.Add(SeqNoMetaDataKey, metadata.SequenceNr.ToString()); await blob.UploadFromByteArrayAsync( snapshotData, 0, snapshotData.Length, AccessCondition.GenerateEmptyCondition(), GenerateOptions(), new OperationContext(), cts.Token); } }
protected override async Task SaveAsync(SnapshotMetadata metadata, object snapshot) { var blobClient = Container.GetBlockBlobClient(metadata.ToSnapshotBlobId()); var snapshotData = _serialization.SnapshotToBytes(new Serialization.Snapshot(snapshot)); using var cts = new CancellationTokenSource(_settings.RequestTimeout); var blobMetadata = new Dictionary <string, string> { [TimeStampMetaDataKey] = metadata.Timestamp.Ticks.ToString(), /* * N.B. No need to convert the key into the Journal format we use here. * The blobs themselves don't have their sort order affected by * the presence of this metadata, so we should just save the SeqNo * in a format that can be easily deserialized later. */ [SeqNoMetaDataKey] = metadata.SequenceNr.ToString() }; using var stream = new MemoryStream(snapshotData); await blobClient.UploadAsync( stream, metadata : blobMetadata, cancellationToken : cts.Token); }
protected override async Task DeleteAsync(SnapshotMetadata metadata) { var blob = Container.GetBlockBlobReference(metadata.ToSnapshotBlobId()); using (var cts = new CancellationTokenSource(_settings.RequestTimeout)) { await blob.DeleteIfExistsAsync(DeleteSnapshotsOption.None, AccessCondition.GenerateIfExistsCondition(), GenerateOptions(), new OperationContext(), cts.Token); } }