Example #1
0
        public async Task ReplaceLatestIndexedAsync(
            DownloadData newData,
            IAccessCondition accessCondition)
        {
            using (_telemetryService.TrackReplaceLatestIndexedDownloads(newData.Count))
            {
                var blobName = GetLatestIndexedBlobName();
                _logger.LogInformation("Replacing the latest indexed downloads from {BlobName}.", blobName);

                var blobReference = Container.GetBlobReference(blobName);

                using (var stream = await blobReference.OpenWriteAsync(accessCondition))
                    using (var streamWriter = new StreamWriter(stream))
                        using (var jsonTextWriter = new JsonTextWriter(streamWriter))
                        {
                            blobReference.Properties.ContentType = "application/json";
                            Serializer.Serialize(jsonTextWriter, newData);
                        }
            }
        }