Skip to content

Instantly share code, notes, and snippets.

@sebfia
Created March 8, 2018 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebfia/abe768c0b19239d0c187bda8cae44f9a to your computer and use it in GitHub Desktop.
Save sebfia/abe768c0b19239d0c187bda8cae44f9a to your computer and use it in GitHub Desktop.
//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