Esempio n. 1
0
        public async Task UploadChangeHistoryAsync(IReadOnlyList <string> packageIds)
        {
            if (packageIds.Count == 0)
            {
                throw new ArgumentException("The list of package IDs must have at least one element.", nameof(packageIds));
            }

            using (_telemetryService.TrackUploadOwnerChangeHistory(packageIds.Count))
            {
                var timestamp = DateTimeOffset.UtcNow.ToString("yyyy-MM-dd-HH-mm-ss-FFFFFFF");
                var blobName  = $"{_options.Value.NormalizeStoragePath()}owners/changes/{timestamp}.json";
                _logger.LogInformation("Uploading owner changes to {BlobName}.", blobName);

                var blobReference = Container.GetBlobReference(blobName);

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