4

入力ファイルを処理し、ex のためにある場所に出力したいと思います。FTP または Azure ストレージ。SaasFile 入出力で Azure Function を使用しようとしています。以下のエラーが表示されます:

2016-07-14T00:44:53 Welcome, you are now connected to log-streaming service. 2016-07-14T00:45:00.580 Script for function 'HttpTriggerCSharp1' changed. Reloading. 2016-07-14T00:45:00.580 Compiling function script. 2016-07-14T00:45:00.721 run.csx(24,25): error CS0622: Can only use array initializer expressions to assign to array types. Try using a new expression instead. 2016-07-14T00:45:00.721 Compilation failed.

ここに私の関数の署名があります:

public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, string output, TraceWriter log)

バインディング:

{
  "bindings": [
    {
      "authLevel": "function",
      "name": "req",
      "type": "httpTrigger",
      "direction": "in"
    },
    {
      "name": "res",
      "type": "http",
      "direction": "out"
    },
    {
      "type": "apiHubFile",
      "name": "output",
      "path": "path/{file}",
      "connection": "ftp_FTP",
      "direction": "out"
    }
  ],
  "disabled": false
}

Run署名に何かが欠けていると思います。Azure のドキュメントで見つけられませんでした。

FTP と Azure Storage を使用して処理する方法を理解するのに助けが必要です。ご協力いただきありがとうございます。

4

4 に答える 4

1

特定のファイル名に出力すると仮定して、これを行う方法の 1 つを次に示します。この例では、ドロップボックス ファイルにバインドしています。

using System.Net;

public static HttpResponseMessage Run(HttpRequestMessage req, TraceWriter log, out string output)
{
    output = req.Content.ReadAsStringAsync().GetAwaiter().GetResult();

    return req.CreateResponse(HttpStatusCode.OK);   
}

bindings:
{
  "bindings": [
    {
      "authLevel": "function",
      "name": "req",
      "type": "httpTrigger",
      "direction": "in"
    },
    {
      "type": "http",
      "name": "res",
      "direction": "out"
    },
    {
      "type": "apiHubFile",
      "name": "output",
      "path": "path/b.txt",
      "connection": "dropbox_DROPBOX",
      "direction": "out",
    }
  ],
  "disabled": false
}

異なるファイル名にバインドするには、入力または入力トリガーを用意し、ファイル名を出力に渡す必要があります。他のすべてのサンプルと同じです。

于 2016-07-15T18:50:26.677 に答える
0

これには http トリガーは必要ありません。ドロップボックスの新しいファイルのフォルダー (input-cs) を監視し、そのファイルを googledrive のフォルダー (output-cs) にコピーする例を次に示します。

using System;

public static void Run(string input, out string output, TraceWriter log)
{
    output = input;
}

バインディング:

{

 "bindings": [
    {
      "type": "apiHubFileTrigger",
      "name": "input",
      "direction": "in",
      "path": "input-cs/{name}",
      "connection": "dropbox_DROPBOX"
    },
    {
      "type": "apiHubFile",
      "name": "output",
      "direction": "out",
      "path": "output-cs/{name}",
      "connection": "googledrive_GOOGLEDRIVE"
    }
  ],
  "disabled": false
}
于 2016-07-15T20:35:25.687 に答える