Created
June 8, 2017 12:45
-
-
Save malteb247/6609c54c2ebb54997a03cd3abb331698 to your computer and use it in GitHub Desktop.
Save a file from azure batch task into linked blob storage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static Main() | |
{ | |
var outputFile = $"results_{taskId}.txt"; | |
using (var output = File.CreateText(WorkingDir(outputFile))) | |
{ | |
output.WriteLine("This is the results file"); | |
} | |
// Persist the task output to Azure Storage | |
Task.WaitAll( | |
taskStorage.SaveAsync(TaskOutputKind.TaskOutput, outputFile) | |
); | |
// We are tracking the disk file to save our standard output, but the node agent may take | |
// up to 3 seconds to flush the stdout stream to disk. So give the file a moment to catch up. | |
await Task.Delay(2000); | |
} | |
private static string WorkingDir(string path) | |
{ | |
return Path.Combine(Environment.GetEnvironmentVariable("AZ_BATCH_TASK_WORKING_DIR") ?? string.Empty, path); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment