Ejemplo n.º 1
0
            private async Task RunOperationManualPollAsync(int icm)
            {
                try
                {
                    ExecuteOperationResponse operationRunning = await client.Operations.RunOperationAsync(operationRequest);

                    while (true)
                    {
                        OperationResult status = await client.Operations.GetOperationStatusAsync(operationRunning.Id);

                        if (status.Status.IsStateComplete())
                        {
                            // Operation reached a final state, get the result.
                            operationResult = await client.Operations.GetOperationResultsAsync(operationRunning.Id);

                            Log.Verbose("Operation has completed execution for {0}: {1}. Operation Result is:{2}{3}", extensionName, operationName, System.Environment.NewLine, operationResult.ResultMessage);
                            // We upload all results of all operations
                            SALsA.GetInstance(icm)?.TaskManager.AddTask(
                                BlobStorage.UploadText(icm, String.Format("action/{1}-{0}_{2}.txt", extensionName, operationName, Log.UID),
                                                       operationResult.ResultMessage));
                            return;
                        }
                        // Warning: Setting too short a delay could result in requests being throttled
                        Log.Verbose("Operation <{0}: {1}> is still in process, polling status again in 5 seconds", extensionName, operationName);
                        await Task.Delay(5000);
                    }
                }

                catch (Exception ex)
                {
                    Log.Error("Operation <{0}: {1}> execution failed.", extensionName, operationName);
                    Log.Exception(ex);
                }
            }
Ejemplo n.º 2
0
        public static async Task SaveAndSendBlobTask(string name, Task <String> task, int Id)
        {
            name = Utility.FormatFileName(Id, name);
            var output = await task;
            await BlobStorage.UploadText(Id, name, output);

            SendSASToICM(name, Id);
            Utility.SaveToFile(name, output, Id);
        }
Ejemplo n.º 3
0
 public static string UploadICMRun(int Id, string html)
 {
     try
     {
         var currentTime = DateTime.UtcNow.ToString("yyMMddTHHmmss", CultureInfo.InvariantCulture);
         var blobName    = String.Format("{0}-{1}_{2}_{3}{4}", Constants.LogICMFileNamePrefix, Log.UID,
                                         currentTime, Id, Constants.LogICMExtension);
         BlobStorage.UploadText(Id, blobName, html, "text/html").GetAwaiter().GetResult();
         BlobStorage.UploadText(Id, Constants.LogICMQuick, html, "text/html").GetAwaiter().GetResult();
         var sas = BlobStorage.GetSASToken(Id, blobName);
         Log.Information("ICM log for this run are available here : {0}", sas);
         return(sas);
     }
     catch (Exception ex)
     {
         Log.Warning("Failed to upload ICM log for this run");
         Log.Exception(ex);
         return(null);
     }
 }