Azure Functions 和 F# Json 类型提供程序
Azure Functions and F# Json Type Provider
我第一次在 Azure Functions 中使用 F# 类型提供程序。这是 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>) =
()
这是 project.json 文件:
{
"frameworks": {
"net46": {
"dependencies": {
"FSharp.Data": "2.3.2"
}
}
}
}
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'
有什么建议吗?
谢谢
我在遇到类似问题时找到了解决方法 - 使用 __SOURCE_DIRECTORY__
值(常量?符号?我不确定它到底是什么):
[<Literal>]
let sample = __SOURCE_DIRECTORY__ + "/sample.json"
type Tweet = JsonProvider<sample>
我很想知道是否有更好的方法来指定它。
我第一次在 Azure Functions 中使用 F# 类型提供程序。这是 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>) =
()
这是 project.json 文件:
{
"frameworks": {
"net46": {
"dependencies": {
"FSharp.Data": "2.3.2"
}
}
}
}
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'
有什么建议吗? 谢谢
我在遇到类似问题时找到了解决方法 - 使用 __SOURCE_DIRECTORY__
值(常量?符号?我不确定它到底是什么):
[<Literal>]
let sample = __SOURCE_DIRECTORY__ + "/sample.json"
type Tweet = JsonProvider<sample>
我很想知道是否有更好的方法来指定它。