Azure functions Azure函数和F#Json类型提供程序

Azure functions Azure函数和F#Json类型提供程序,azure-functions,f#-data,Azure Functions,F# Data,我第一次在Azure函数中使用F#Type提供程序。以下是run.fsx文件: #r "FSharp.Data" #r "Microsoft.WindowsAzure.Storage" open System open FSharp.Data open Microsoft.WindowsAzure.Storage.Table type Tweet = JsonProvider<"sample.json"> let Run (queueItem: string, tweets:

我第一次在Azure函数中使用F#Type提供程序。以下是run.fsx文件:

#r "FSharp.Data"
#r "Microsoft.WindowsAzure.Storage"

open System
open FSharp.Data
open Microsoft.WindowsAzure.Storage.Table

type Tweet = JsonProvider<"sample.json">

let Run (queueItem: string, tweets: ICollector<Tweet>) =  
    ()
sample.json与其他文件位于同一文件夹中

当我运行它时,我得到以下信息:

> 2017-02-06T13:40:22.946 > D:\home\site\wwwroot\TweeterDataCleaner\run.fsx(9,14): error FS3033: > The type provider 'ProviderImplementation.JsonProvider' reported an > error: Cannot read sample JSON from 'sample.json': Could not find file > 'D:\Windows\system32\sample.json' >2017-02-06T13:40:22.946 >D:\home\site\wwwroot\TweeterDataCleaner\run.fsx(9,14):错误FS3033: >类型提供程序“ProviderImplementation.JsonProvider”报告 >错误:无法从“sample.JSON”读取样本JSON:找不到文件 >'D:\Windows\system32\sample.json' 有什么建议吗?
谢谢

当我遇到类似问题时,我找到了一个解决方法-使用
\uuu源代码\uu目录\uuu
值(常量?符号?我不确定它到底是什么):

[]
让sample=\uuuuu源目录\uuuu+“/sample.json”
键入Tweet=JsonProvider

我很想知道是否有更好的方法来说明这一点。

这很有效-谢谢。我问Don Syme源目录是什么,他说“呃,是黑客吗?”理想情况下,Azure函数会将函数执行的工作目录设置为该函数。目前,情况并非如此。SOURCE_目录看起来像一个宏,解析为F#源文件的目录,类似于:$env:HOME+'/site/wwwroot/'。这绝对是目前最简单的方法,因为我相信更改函数工作目录也可以修改其他.net函数的工作目录。以上模式(使用HOME环境变量+path)是目前推荐的方法。我们计划以一种更方便的方式来展示这一点,这样你就不必跳过障碍。 > 2017-02-06T13:40:22.946 > D:\home\site\wwwroot\TweeterDataCleaner\run.fsx(9,14): error FS3033: > The type provider 'ProviderImplementation.JsonProvider' reported an > error: Cannot read sample JSON from 'sample.json': Could not find file > 'D:\Windows\system32\sample.json'
[<Literal>]
let sample = __SOURCE_DIRECTORY__ + "/sample.json"
type Tweet = JsonProvider<sample>