Use the OData service to access Azure data market data source

Category:
TypeProviders.ODataService
Description: Use the OData service to access Azure data market data source. For this sample, we access the UK travel information data from Azure data market. You need Azure data maket user name and credential to access this free data.
Code:

type TOData = Microsoft.FSharp.Data.TypeProviders.ODataService< ServiceUri = @"https://api.datamarket.azure.com/Uk.Gov/TravelAdvisoryService/" >

let typeProviderODataSample() =
let travelInfo = TOData.GetDataContext()
//To sign up for a Windows Azure Marketplace account @ https://datamarket.azure.com/account/info
do travelInfo.Credentials <- new NetworkCredential (Utils.ADM_USER_ID, Utils.ADM_ACCOUNT_ID)

query {
for n in travelInfo.BritishEmbassiesAndHighCommissions do
select n
take 2
} |> Seq.iter (fun n -> printfn "%s\n" n.Address)

// sample output
// 1A Brisbane Street
// Hobart
// Tasmania
// 7000
// ,Hobart
//
// 444-446 Pulteney Street
// Adelaide
// SA 5000
// ,Adelaide

Execution Result:
1A Brisbane Street
Hobart
Tasmania
7000
,Hobart

444-446 Pulteney Street
Adelaide
SA 5000
,Adelaide


Last edited Mar 1, 2012 at 7:04 PM by ttliu2000, version 5

Comments

No comments yet.