/// <summary> /// Delete a job and all cloud storage associated with the job. /// </summary> /// <param name="jobID">ID of the job.</param> /// <param name="ct">Cancellation token.</param> public async Task DeleteJobAsync(string jobID, CancellationToken ct) { Guid parsedID = Guid.Parse(jobID); // Delete cloud storage associated with the job. await storageClient.GetContainerReference(StorageConstants.GetJobOutputContainer(parsedID)).DeleteIfExistsAsync(ct); if (ct.IsCancellationRequested) { return; } await storageClient.GetContainerReference(StorageConstants.GetJobContainer(parsedID)).DeleteIfExistsAsync(ct); if (ct.IsCancellationRequested) { return; } await storageClient.GetContainerReference(jobID).DeleteIfExistsAsync(ct); if (ct.IsCancellationRequested) { return; } // Delete the job. await batchClient.JobOperations.DeleteJobAsync(jobID, cancellationToken : ct); }
/// <summary> /// Lists all output files of a given job. /// </summary> /// <param name="jobID">Job ID.</param> /// <param name="ct">Cancellation token.</param> private async Task<List<CloudBlockBlob>> GetJobOutputs(Guid jobID, CancellationToken ct) { CloudBlobContainer containerRef = storageClient.GetContainerReference(StorageConstants.GetJobOutputContainer(jobID)); if (!await containerRef.ExistsAsync(ct) || ct.IsCancellationRequested) return null; return await containerRef.ListBlobsAsync(ct); }
private IEnumerable <CloudBlockBlob> ListJobOutputsFromStorage() { var containerRef = blobClient.GetContainerReference(StorageConstants.GetJobOutputContainer(jobId)); if (!containerRef.Exists()) { return(Enumerable.Empty <CloudBlockBlob>()); } return(containerRef.ListBlobs().Select(b => ((CloudBlockBlob)b))); }
/// <summary> /// Counts the number of blobs in a cloud storage container. /// </summary> /// <param name="jobId">Id of the container.</param> /// <param name="includeDebugFiles">Whether or not to count debug file blobs.</param> /// <returns></returns> private int CountBlobs() { try { CloudBlobContainer container = blobClient.GetContainerReference(StorageConstants.GetJobOutputContainer(jobId)); container.FetchAttributes(); int count = 0; var blobs = container.ListBlobs(); foreach (var blob in blobs) { string extension = Path.GetExtension(blob.Uri.LocalPath.ToLower()); if (saveDebugFiles || !(extension == ".stdout" || extension == ".sum")) { count++; } } return(count); } catch { return(0); } }