public async Task <PackageStreamMetadata> UpdatePackageBlobMetadataAsync(PackageValidationSet validationSet) { var fileName = BuildFileName( validationSet, _fileMetadataService.FileSavePathTemplate, _fileMetadataService.FileExtension); PackageStreamMetadata streamMetadata = null; // This will throw if the ETag changes between read and write operations, // so streamMetadata will never be null. await _fileStorageService.SetMetadataAsync( _fileMetadataService.FileFolderName, fileName, async (lazyStream, metadata) => { var packageStream = await lazyStream.Value; string hash; using (_telemetryService.TrackDurationToHashPackage( validationSet.PackageId, validationSet.PackageNormalizedVersion, validationSet.ValidationTrackingId, packageStream.Length, CoreConstants.Sha512HashAlgorithmId, packageStream.GetType().FullName)) { hash = CryptographyService.GenerateHash(packageStream, CoreConstants.Sha512HashAlgorithmId); } metadata[CoreConstants.Sha512HashAlgorithmId] = hash; streamMetadata = new PackageStreamMetadata() { Size = packageStream.Length, Hash = hash, HashAlgorithm = CoreConstants.Sha512HashAlgorithmId }; return(true); }); return(streamMetadata); }