Exemplo n.º 1
0
        public async Task ReplaceLatestIndexedAsync(
            PopularityTransferData newData,
            IAccessCondition accessCondition)
        {
            using (_telemetryService.TrackReplaceLatestIndexedPopularityTransfers(newData.Count))
            {
                var blobName = GetLatestIndexedBlobName();
                _logger.LogInformation("Replacing the latest indexed popularity transfers from {BlobName}.", blobName);

                var mappedAccessCondition = new AccessCondition
                {
                    IfNoneMatchETag = accessCondition.IfNoneMatchETag,
                    IfMatchETag     = accessCondition.IfMatchETag,
                };

                var blobReference = Container.GetBlobReference(blobName);

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