代码之家  ›  专栏  ›  技术社区  ›  Mark Allison

如何使用c_中的Azure函数读取blob输入绑定中的XML文件?

  •  0
  • Mark Allison  · 技术社区  · 6 年前

    当使用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?)
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Roman Kiss    6 年前

    添加Nuget包 Microsoft.azure.webjobs.extensions.storage(Microsoft.azure.webjobs.extensions.存储)