如何让c脚本Azure函数从c驱动器读取文件,写入blob存储?

如何让c脚本Azure函数从c驱动器读取文件,写入blob存储?,azure,azure-functions,Azure,Azure Functions,我需要一个c脚本Azure函数来从c驱动器读取文件,并将其写入blob存储帐户。我想我对如何写这个文件有些了解,但我该如何读呢 我是一个试图理解函数的powershell家伙,对我放松点!我在想象一个网页,它允许在C驱动器上选择一个文件,包含如下内容: <label for="Image">Select the image file to upload: </label><input type="file" name="Image" />. 对于您提到的用

我需要一个c脚本Azure函数来从c驱动器读取文件,并将其写入blob存储帐户。我想我对如何写这个文件有些了解,但我该如何读呢

我是一个试图理解函数的powershell家伙,对我放松点!我在想象一个网页,它允许在C驱动器上选择一个文件,包含如下内容:

<label for="Image">Select the image file to upload: </label><input type="file" name="Image" />. 

对于您提到的用例,我没有带有C示例代码的Azure函数,但是,我可以将您连接到能够提供帮助的人。请PM我

您是否也考虑过使用Azure data factory将数据复制到Azure Blob存储或从中复制数据?或者,您可以评估


Aung Oo,Microsoft Azure Storage Engineering

当你说C驱动器时,从Azure功能看,你是在试图访问某种网络共享路径吗?@DixitArora MSFT是的,是的,我试图在网站上填写表单的人的计算机上的网络共享或C驱动器。用户将选择该文件并单击链接触发该功能,该功能将从C驱动器或网络共享读取该文件,并将其上载到blob存储。无论如何,这就是计划…@aberdeenangus函数应用程序沙盒明确不允许访问SMB协议137/138/139/445所需的端口。本文在受限传出端口下提到它:。假设不是您的函数读取您的c驱动程序文件,而是您的web读取您的文件,然后使用文件二进制或流请求调用您的HTTP触发器函数。@DixitArora MSFT谢谢大家!是的,我真是一头驴,希望在几英里外的微软虚拟机上运行一些代码,以便能够访问我笔记本电脑的C驱动器。我将尝试更多地了解网页如何从我的C驱动器读取文件,然后调用函数的http触发器?我看不到任何可以点击的东西,我已经在谷歌上搜索并阅读到Stackoverflow没有PM设备。
#r "Newtonsoft.Json"
#r "Microsoft.AspNetCore.Mvc"

using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
//added by me
using Microsoft.Azure.Storage.Blob;
using Microsoft.Azure.Storage;

public static async Task<IActionResult> Run(HttpRequest req, TextWriter myOutputBlob, ILogger log)
{
    log.LogInformation("C# HTTP trigger function processed a request.");

    // I think we're using the Namespace: Microsoft.AspNetCore.Http
    string name = req.Query["name"];

    string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
    dynamic data = JsonConvert.DeserializeObject(requestBody);
    name = name ?? data?.name;
    myOutputBlob.Write(name);

    return name != null
        ? (ActionResult)new OkObjectResult($"Hello, {name}")
        : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
}
{
  "bindings": [
    {
      "authLevel": "function",
      "name": "req",
      "type": "httpTrigger",
      "direction": "in",
      "methods": [
        "get",
        "post"
      ]
    },
    {
      "name": "$return",
      "type": "http",
      "direction": "out"
    },
    {
      "name": "myOutputBlob",
      "type": "blob",
      "path": "myfolder/myBlob-%myValue%-{rand-guid}.txt",
      "connection": "",
      "direction": "out"
    }
  ]
}