尝试使用 azure 函数上传 ftp 的文件
Trying to upload a file with ftp using azure functions
我正在尝试使用外部文件协议和 FTP api 连接发送文件。配置和代码很简单,应用程序运行成功,但是没有数据发送到 FTP,而且我看不到该函数甚至尝试使用 ftp 发送数据的任何痕迹......什么是错误的?更重要的是;在哪里可以监控外部文件的进度api?
我的代码如下(注:我试过 Stream 和 string 作为输入和输出)
run.csx
public static void Run(Stream myBlobInput, string name, out Stream
myFTPOutput, TraceWriter log)
{
myFTPOutput = myBlobInput;
//log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Content:{myBlob}");
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size:{myBlobInput.Length} \n Content:{myBlobInput.ToString()}");
}
function.json
"bindings": [
{
"name": "myBlobInput",
"type": "blobTrigger",
"direction": "in",
"path": "input/{name}",
"connection": "blob_STORAGE"
},
{
"name": "myFTPOutput",
"type": "apiHubFile",
"direction": "out",
"path": "/output/{name}",
"connection": "ftp_FTP"
}
],
"disabled": false
}
我可以让它工作:
如果我们想在输出 FTP 服务器中有相同的文件内容和相同的文件名,那么这里是代码和 function.json
public static void Run(string myBlob, string name, TraceWriter log , out string outputFile )
{
log.Info($"2..C# Blob trigger function Processed blob\n Name:{name} \n Size:{myBlob.Length} \n Content:{myBlob.ToString()}");
outputFile=myBlob;
}
这里还有 function.json
{
"bindings": [
{
"name": "myBlob",
"type": "blobTrigger",
"direction": "in",
"path": "myblobcontainer/{name}",
"connection": "AzureWebJobsDashboard"
},
{
"type": "apiHubFile",
"name": "outputFile",
"path": "LogFiles/{name}",
"connection": "ftp_FTP",
"direction": "out"
}
],
"disabled": false
}
输入绑定应该有一个有效的容器名称,就像这里的 blob 帐户一样--:
blob container structure as path
同样在 FTP 的输出绑定中,路径应该是 FTP 根目录中的任何文件夹,您在 FTP 登录 UI/console 中看到的内容,然后是文件名,在本例中为 {name} ,它允许我们保持与输入 blob 名称相同的输出文件名。
好的,所以我更改了 ftp 到其他服务器的连接,它工作得很好。这意味着触发了 Azure Functions 的一些防火墙拒绝。可悲的是,没有我能发现的错误消息触发。感谢大家的支持
我正在尝试使用外部文件协议和 FTP api 连接发送文件。配置和代码很简单,应用程序运行成功,但是没有数据发送到 FTP,而且我看不到该函数甚至尝试使用 ftp 发送数据的任何痕迹......什么是错误的?更重要的是;在哪里可以监控外部文件的进度api?
我的代码如下(注:我试过 Stream 和 string 作为输入和输出)
run.csx
public static void Run(Stream myBlobInput, string name, out Stream
myFTPOutput, TraceWriter log)
{
myFTPOutput = myBlobInput;
//log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Content:{myBlob}");
log.Info($"C# Blob trigger function Processed blob\n Name:{name} \n Size:{myBlobInput.Length} \n Content:{myBlobInput.ToString()}");
}
function.json
"bindings": [
{
"name": "myBlobInput",
"type": "blobTrigger",
"direction": "in",
"path": "input/{name}",
"connection": "blob_STORAGE"
},
{
"name": "myFTPOutput",
"type": "apiHubFile",
"direction": "out",
"path": "/output/{name}",
"connection": "ftp_FTP"
}
],
"disabled": false
}
我可以让它工作: 如果我们想在输出 FTP 服务器中有相同的文件内容和相同的文件名,那么这里是代码和 function.json
public static void Run(string myBlob, string name, TraceWriter log , out string outputFile )
{
log.Info($"2..C# Blob trigger function Processed blob\n Name:{name} \n Size:{myBlob.Length} \n Content:{myBlob.ToString()}");
outputFile=myBlob;
}
这里还有 function.json
{
"bindings": [
{
"name": "myBlob",
"type": "blobTrigger",
"direction": "in",
"path": "myblobcontainer/{name}",
"connection": "AzureWebJobsDashboard"
},
{
"type": "apiHubFile",
"name": "outputFile",
"path": "LogFiles/{name}",
"connection": "ftp_FTP",
"direction": "out"
}
],
"disabled": false
}
输入绑定应该有一个有效的容器名称,就像这里的 blob 帐户一样--: blob container structure as path
同样在 FTP 的输出绑定中,路径应该是 FTP 根目录中的任何文件夹,您在 FTP 登录 UI/console 中看到的内容,然后是文件名,在本例中为 {name} ,它允许我们保持与输入 blob 名称相同的输出文件名。
好的,所以我更改了 ftp 到其他服务器的连接,它工作得很好。这意味着触发了 Azure Functions 的一些防火墙拒绝。可悲的是,没有我能发现的错误消息触发。感谢大家的支持