Created
March 8, 2018 22:51
-
-
Save sebfia/abe768c0b19239d0c187bda8cae44f9a to your computer and use it in GitHub Desktop.
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
//package Microsoft.WindowsAzure.Storage | |
open Microsoft.WindowsAzure.Storage | |
let getBlobsInDirectory storageKey containerName = | |
let acct = CloudStorageAccount.Parse(storageKey) | |
let client = acct.CreateCloudBlobClient() | |
let container = client.GetContainerReference(containerName) | |
let rec getBlobs (d: string) t blobs = | |
async { | |
let! response = container.ListBlobsSegmentedAsync(d,true,BlobListingDetails.None,Nullable<int>(20),t,null,null) |> Async.AwaitTask | |
let result = response.Results |> Seq.map (fun i -> i :?> CloudBlockBlob) |> Seq.fold (fun s y -> y::s) blobs | |
match response.ContinuationToken with | |
| null -> return result |> List.rev | |
| x -> return! getBlobs d x result | |
} | |
fun (dir: string) -> | |
async { | |
return! getBlobs dir null [] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment