Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用azure function app读取azure blob中的内容_C#_Azure_Azure Storage_Azure Functions - Fatal编程技术网

C# 如何使用azure function app读取azure blob中的内容

C# 如何使用azure function app读取azure blob中的内容,c#,azure,azure-storage,azure-functions,C#,Azure,Azure Storage,Azure Functions,我想在文件上传到容器中并读取文件中的内容时触发函数应用程序。我能够触发功能应用程序。但是当我使用Openread读取文件中的内容时,我得到的是引用未找到错误。下面是我用来读取文件和绑定的代码 #r "System.IO"; using System; using System.Collections.Generic; using System.IO; using System.Configuration; using Microsoft.WindowsAzure.Storage; using

我想在文件上传到容器中并读取文件中的内容时触发函数应用程序。我能够触发功能应用程序。但是当我使用Openread读取文件中的内容时,我得到的是引用未找到错误。下面是我用来读取文件和绑定的代码

#r "System.IO";

using System;
using System.Collections.Generic;
using System.IO;
using System.Configuration;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
using System.Xml;

using Microsoft.Win32;
using System.Net;
using System.Linq;

public static void Run(Stream myBlob, string name, TraceWriter log, string 
inputBlob)
{
    log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: 
    {myBlob.Length} Bytes");
    StreamReader reader = new StreamReader(inputBlob.OpenRead())
    {
        String oldContent = reader.ReadToEnd();
    }
}
绑定

{
    "bindings": [{
            "name": "myBlob",
            "type": "blobTrigger",
            "direction": "in",
            "path": "sample/{name}",
            "connection": "testforfunctionapp_STORAGE"
        }, {
            "type": "blob",
            "name": "inputBlob",
            "path": "sample/{name}",
            "connection": "testforfunctionapp_STORAGE",
            "direction": "in"
        }
    ],
    "disabled": false
}
有谁能帮忙吗


谢谢

我没有看到GetblobReference,这可能是问题的原因:

 var blob = container.GetBlobReference("testblob.txt");

        blob.UploadText(new String('x', 5000000));

        var source = blob.OpenRead();
您可以查看官方文档以获取它

我还建议您检查一下这个

中的示例,您可以按照这个创建一个blob触发器

我正在获取未找到的引用错误

在您的情况下,
inputBlob
是字符串类型,您不能使用
inputBlob.OpenRead()
。并且不需要额外的绑定
inputBlob

请尝试使用以下代码。对我来说,它工作正常

#r "System.IO"

using System;
using System.Collections.Generic;
using System.IO;
public static void Run(Stream myBlob, string name, TraceWriter log)
{
    log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
    StreamReader reader = new StreamReader(myBlob);
    string  oldContent = reader.ReadToEnd();
    log.Info($"oldContent:{oldContent}");

}

谢谢你的帮助。这是有效的。请告诉我,当文件上传到sftp时,我们是否可以触发功能应用程序。我已检查了集成-->触发器-->外部文件。我们有一个SFTP选项,我在那里创建了SFTP连接。但是,当文件上传到sftp时,我的函数不会被触发。你能帮我一下吗?扳机应该能用的,你可以参考一下。你也可以在新的SO线程中创建一个带有详细描述的新线程。我已经创建了Biddings。但不确定功能应用程序未触发的原因是什么。我已经在这里贴出了单独的带有约束力的问题