public async static Task UploadArtifactToStorage(BlobUploadContext uploadContext)
        {
            string containerName = $"{uploadContext.Worker}-{uploadContext.Platform}-{uploadContext.Environment}";
            string blobName      = $"results-{Guid.NewGuid().ToString()}.zip";

            string artifactUrl = uploadContext?.Artifact?.Resource?.DownloadUrl
                                 ?? throw new ArgumentNullException("Could not retrieve the download Url from the context.");

            using (HttpClient client = new HttpClient())
            {
                using (HttpResponseMessage response = await client.GetAsync(new Uri(artifactUrl)))
                    using (Stream downloadStream = await response.Content.ReadAsStreamAsync())
                    {
                        await UploadStreamToStorage(blobName, containerName, downloadStream);
                    }
            }
        }
示例#2
0
 public static void UploadToStorage([ActivityTrigger] BlobUploadContext uploadContext, ILogger log)
 {
     log.LogInformation($"Uploading the test artifacts for worker {uploadContext.Worker}...");
     StorageHelper.UploadArtifactToStorage(uploadContext).Wait();
 }