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
#r @"C:\wd\AzureTxnUploader\packages\WindowsAzure.Storage.2.0.6.0\lib\net40\Microsoft.WindowsAzure.Storage.dll" | |
#r @"C:\wd\AzureTxnUploader\packages\Microsoft.Data.OData.5.2.0\lib\net40\Microsoft.Data.OData.dll" | |
#r @"C:\wd\AzureTxnUploader\packages\Microsoft.Data.Edm.5.2.0\lib\net40\Microsoft.Data.Edm.dll" | |
#r @"C:\wd\AzureTxnUploader\packages\System.Spatial.5.2.0\lib\net40\System.Spatial.dll" | |
#r "Microsoft.WindowsAzure.ServiceRuntime" | |
open System | |
open Microsoft.WindowsAzure | |
open Microsoft.WindowsAzure.Storage | |
// Account name and key. Modify for your account. | |
let accountName = "someAccountName" | |
let accountKey = "someAccountKey" | |
//Get a reference to the storage account, with authentication credentials | |
let credentials = new Auth.StorageCredentials(accountName, accountKey) | |
let storageAccount = new CloudStorageAccount(credentials, true) | |
storageAccount.TableEndpoint = Uri("http://bohszy.table.core.windows.net/") | |
let tableClient = storageAccount.CreateCloudTableClient() | |
// start by retrieving a specific example entity | |
let txnTable = tableClient.GetTableReference("someTable") | |
let tableOperation = Table.TableOperation.Retrieve("2007-1", "1-1") | |
let tableResult = txnTable.Execute(tableOperation) | |
let properties = (tableResult.Result :?> Table.DynamicTableEntity).Properties // returns a dictionary from which we need to extract txnJson key-value | |
let json = properties.Item("txnJson").StringValue | |
// that worked, so lets retrieve a bunch more | |
[1 .. 1000] |> List.map(fun i -> txnTable.Execute(Table.TableOperation.Retrieve((sprintf "2007-%i" i), "1-1"))) | |
// and what about a query that brings back multiple results... | |
let dynQuery = (new Table.TableQuery()).Where("PartitionKey lt '2013'").Select([|"txnJson"|] :> System.Collections.Generic.IList<string> ) | |
let results = txnTable.ExecuteQuery(dynQuery) | |
// interesting to run results.GetType() | |
results | |
//|> Seq.take 4 | |
|> Seq.iter (fun i -> printfn "Json: %s" (i.Properties.Item("txnJson").StringValue) ) |