0

当使用 Http 触发器调用我的 Azure 函数时,我想从 blob 存储读取 XML 文件。我该怎么做?我看过很多不同的例子,但似乎没有一个对我有用。该函数在没有 Blob 输入绑定的情况下工作正常,但我想在每次调用它时从 Blob 存储中读取文件。

我试过了:

    public static async Task<IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
        [Blob("config/log4netConfig.xml", FileAccess.Read)] Stream configFile,            
        ILogger log)
    {
        XmlDocument doc = new XmlDocument();
        using (XmlReader reader = XmlReader.Create(configFile))
        {
            doc.Load(reader);
        }            

在上面的代码中,VS2017 不理解 Blob 属性并出现错误:

Error CS0246 The type or namespace name 'BlobAttribute' could not be found (are you missing a using directive or an assembly reference?)
4

1 回答 1

1

添加一个 nuget 包Microsoft.Azure.WebJobs.Extensions.Storage

于 2019-01-05T14:34:51.613 回答