如何在 C# 中使用 Azure Functions 读取 blob 输入绑定中的 XML 文件?

How to read an XML file in a blob input binding with Azure Functions in C#?

我想在使用 Http 触发器调用我的 Azure 函数时从 blob 存储中读取 XML 文件。我应该怎么做?我看过许多不同的示例,但其中 none 似乎对我有用。该函数在没有 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?)

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