static void Main(string[] args) { loggerFactory = new LoggerFactory(); logger = loggerFactory.CreateLogger <Program>(); loggerFactory.AddConsole(LogLevel.Debug); // for now emit all logging info, TODO: make configurable? var relativePath = System.Environment.GetEnvironmentVariable(RelavePathEnvironmentVariable); var pat = System.Environment.GetEnvironmentVariable(VSTSPatEnvironmentVariable); var destination = System.Environment.GetEnvironmentVariable(DropDestinationEnvironmentVariable) ?? DefaultDropDestination; var url = System.Environment.GetEnvironmentVariable(DropUrlEnvironmentVariable) ?? ExtractDropUrl(destination); // sample URL: // https://msasg.artifacts.visualstudio.com/DefaultCollection/_apis/drop/drops/Aether_master/7dd31c59986465bfa9af3bd883cb35ce132979a2/e90d7f94-265a-86c7-5958-66983fdcaa06 logger.LogInformation($"url: {url}"); // /Release/Amd64/app/aether/AetherBackend logger.LogInformation($"relative path: {relativePath}"); logger.LogInformation($"destination: {destination}"); var proxy = new VSTSDropProxy(url, relativePath, pat, loggerFactory); var sw = Stopwatch.StartNew(); proxy.Materialize(destination).Wait(); sw.Stop(); logger.LogInformation($"Finished in {sw.Elapsed}"); }
static void Main(string[] args) { var relativePath = System.Environment.GetEnvironmentVariable(RelavePathEnvironmentVariable) ?? "/"; var pat = System.Environment.GetEnvironmentVariable(VSTSPatEnvironmentVariable); if (string.IsNullOrWhiteSpace(pat) || pat.Equals("$(System.AccessToken)")) { throw new ArgumentException("Invalid personal accestoken. Remember to set allow scripts to access oauth token in agent phase"); } var destination = System.Environment.GetEnvironmentVariable(DropDestinationEnvironmentVariable) ?? DefaultDropDestination; var url = System.Environment.GetEnvironmentVariable(DropUrlEnvironmentVariable) ?? ExtractDropUrl(destination); // sample URL: // https://msasg.artifacts.visualstudio.com/DefaultCollection/_apis/drop/drops/Aether_master/7dd31c59986465bfa9af3bd883cb35ce132979a2/e90d7f94-265a-86c7-5958-66983fdcaa06 Console.WriteLine($"url: {url}"); // /Release/Amd64/app/aether/AetherBackend Console.WriteLine($"relative path: {relativePath}"); Console.WriteLine($"destination: {destination}"); var proxy = new VSTSDropProxy(url, relativePath, pat); var sw = Stopwatch.StartNew(); proxy.Materialize(destination).Wait(); sw.Stop(); Console.WriteLine($"Finished in {sw.Elapsed}"); }
static int Run(Args a) { var props = new Dictionary <string, string>(); var metrics = new Dictionary <string, double>(); var sw = Stopwatch.StartNew(); try { a.Validate(); var url = a.DropUrl ?? ExtractDropUrl(a.DropDestination); props["url"] = url; // sample URL: // https://msasg.artifacts.visualstudio.com/DefaultCollection/_apis/drop/drops/blahblah/7dd31c59986465bfa9af3bd883cb35ce132979a2/e90d7f94-265a-86c7-5958-66983fdcaa06 Console.WriteLine($"url: {url}"); Console.WriteLine($"relative path: {a.RelativePath}"); Console.WriteLine($"destination: {a.DropDestination}"); var proxy = new VSTSDropProxy(url, a.RelativePath, a.VstsPat, TimeSpan.FromSeconds(a.BlobTimeoutSeconds), a.RetryCount, a.SoftLinks, a.CacheLocation, a.ConcurrentDownloads, a.ComputeDockerHashes); metrics = proxy.Materialize(a.DropDestination).Result; Console.WriteLine($"Finished in {sw.Elapsed}"); props["success"] = "True"; return(0); } catch (Exception e) { props["success"] = "False"; props["exception"] = e.ToString(); Console.WriteLine($"Unhandled exception: {e.ToString()}"); return(1); } finally { metrics["Elapsed"] = sw.Elapsed.TotalSeconds; foreach (var metric in metrics) { Console.WriteLine($"{metric.Key} = {metric.Value}"); } } }
static void Run(Args a) { var telemetry = new TelemetryClient(new TelemetryConfiguration(a.InstrumentationKey)); //https://docs.microsoft.com/en-us/dotnet/api/microsoft.applicationinsights.telemetryclient.trackevent?view=azure-dotnet var props = new Dictionary <string, string>(); var metrics = new Dictionary <string, double>(); var sw = Stopwatch.StartNew(); try { a.Validate(); var url = a.DropUrl ?? ExtractDropUrl(a.DropDestination); props["url"] = url; // sample URL: // https://msasg.artifacts.visualstudio.com/DefaultCollection/_apis/drop/drops/Aether_master/7dd31c59986465bfa9af3bd883cb35ce132979a2/e90d7f94-265a-86c7-5958-66983fdcaa06 Console.WriteLine($"url: {url}"); // /Release/Amd64/app/aether/AetherBackend Console.WriteLine($"relative path: {a.RelativePath}"); Console.WriteLine($"destination: {a.DropDestination}"); var proxy = new VSTSDropProxy(url, a.RelativePath, a.VstsPat, TimeSpan.FromSeconds(a.BlobTimeoutSeconds)); metrics = proxy.Materialize(a.DropDestination).Result; Console.WriteLine($"Finished in {sw.Elapsed}"); props["success"] = "True"; } catch (Exception e) { props["success"] = "False"; props["exception"] = e.ToString(); throw; } finally { metrics["Elapsed"] = sw.Elapsed.TotalSeconds; telemetry.TrackEvent("dropdownloader", props, metrics); telemetry.Flush(); } }