• <small id='ycdy9'></small><noframes id='ycdy9'>

  • <i id='ycdy9'><tr id='ycdy9'><dt id='ycdy9'><q id='ycdy9'><span id='ycdy9'><b id='ycdy9'><form id='ycdy9'><ins id='ycdy9'></ins><ul id='ycdy9'></ul><sub id='ycdy9'></sub></form><legend id='ycdy9'></legend><bdo id='ycdy9'><pre id='ycdy9'><center id='ycdy9'></center></pre></bdo></b><th id='ycdy9'></th></span></q></dt></tr></i><div id='ycdy9'><tfoot id='ycdy9'></tfoot><dl id='ycdy9'><fieldset id='ycdy9'></fieldset></dl></div>
    <legend id='ycdy9'><style id='ycdy9'><dir id='ycdy9'><q id='ycdy9'></q></dir></style></legend>

      <tfoot id='ycdy9'></tfoot>

          <bdo id='ycdy9'></bdo><ul id='ycdy9'></ul>

        azure function c# http trigger blob output

        时间:2023-10-25

      1. <i id='6FJtg'><tr id='6FJtg'><dt id='6FJtg'><q id='6FJtg'><span id='6FJtg'><b id='6FJtg'><form id='6FJtg'><ins id='6FJtg'></ins><ul id='6FJtg'></ul><sub id='6FJtg'></sub></form><legend id='6FJtg'></legend><bdo id='6FJtg'><pre id='6FJtg'><center id='6FJtg'></center></pre></bdo></b><th id='6FJtg'></th></span></q></dt></tr></i><div id='6FJtg'><tfoot id='6FJtg'></tfoot><dl id='6FJtg'><fieldset id='6FJtg'></fieldset></dl></div>

        <small id='6FJtg'></small><noframes id='6FJtg'>

        <legend id='6FJtg'><style id='6FJtg'><dir id='6FJtg'><q id='6FJtg'></q></dir></style></legend>
      2. <tfoot id='6FJtg'></tfoot>
        • <bdo id='6FJtg'></bdo><ul id='6FJtg'></ul>

                  <tbody id='6FJtg'></tbody>

                1. 本文介绍了azure function c# http trigger blob output的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  谁能描述我如何配置使用 HTTP 输入触发器和 blob 存储输出触发器的 C# azure 函数?

                  Can someone describe me how I can configure a C# azure function which uses an HTTP input trigger and a blob storage output trigger?

                  也许还有一个示例代码片段和一个示例 function.json.我无法使用 azure functions 核心工具在本地工作.

                  Maybe also with an example code snippet and an example function.json. I don't get it to work locally with the azure functions core tools.

                  推荐答案

                  这是一个带有输出 blob 绑定的组合 HTTP 触发函数:

                  This is a combined HTTP triggered function with a output blob binding:

                  [FunctionName("HttpTriggeredFunction")]
                  public static async Task<IActionResult> Run(
                      [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest httpRequest,
                      [Blob("blobcontainer", Connection = "StorageConnectionString")] CloudBlobContainer outputContainer,
                      ILogger log)
                  {
                      log.LogInformation("C# HTTP trigger function processed a request.");
                  
                      await outputContainer.CreateIfNotExistsAsync();
                  
                      var requestBody = await new StreamReader(httpRequest.Body).ReadToEndAsync();
                      var blobName = Guid.NewGuid().ToString();
                  
                      var cloudBlockBlob = outputContainer.GetBlockBlobReference(blobName);
                      await cloudBlockBlob.UploadTextAsync(requestBody);
                  
                      return new OkObjectResult(blobName);
                  }
                  

                  它使用 CloudBlobContainer 输出类型来获取对 blob 容器的引用,然后您可以使用诸如 .GetBlockBlobReference("blobPath") 之类的方法来获取对 blob 的引用.

                  It uses the CloudBlobContainer output type to get a reference to the blob container which then enables you to use methods such as .GetBlockBlobReference("blobPath") to get a reference to a blob.

                  一旦你有一个 blob 的引用,你就可以使用不同的方法来上传:

                  Once you have a reference to a blob, you can use different methods to upload:

                  • cloudBlockBlob.UploadFromByteArrayAsync()
                  • cloudBlockBlob.UploadFromFileAsync()
                  • cloudBlockBlob.UploadTextAsync()
                  • cloudBlockBlob.UploadFromStreamAsync()

                  要让它在本地运行,您需要进行一些设置.请注意我的示例中的属性 [Blob("blobcontainer", Connection = "StorageConnectionString")]

                  To get it running locally, you need set some things up. Notice in my example the attribute [Blob("blobcontainer", Connection = "StorageConnectionString")]

                  • "blobcontainer" 这可以是您想要的任何内容,并且将是通过这一行 outputContainer.CreateIfNotExistsAsync(); 在您的存储帐户中创建的容器的名称(如果不是已经存在).
                  • Connection = "StorageConnectionString" 这可以是您的 local.settings.json 中用于存储帐户连接字符串的设置.在本地开发时,我建议将其设置为 "UseDevelopmentStorage=true" 以便您可以利用存储模拟器.然后,当您准备好部署到 Azure 上时,您将在函数应用中创建一个包含实际连接字符串的设置.
                  • "blobcontainer" this can be whatever you want and will be the name of the container that will be created in your storage account by this line outputContainer.CreateIfNotExistsAsync(); (if it doesn't exist already).
                  • Connection = "StorageConnectionString" this can be a setting in your local.settings.json for the connection string of your storage account. When developing locally I would recommend setting this to "UseDevelopmentStorage=true" so that you can take advantage of the storage emulator. Then when you are ready to deploy onto Azure, you would create a setting in the function app containing the real connection string.

                  local.settings.json

                  {
                    "IsEncrypted": false,
                    "Values": {
                      "AzureWebJobsStorage": "UseDevelopmentStorage=true",
                      "FUNCTIONS_WORKER_RUNTIME": "dotnet",
                  
                      "StorageConnectionString": "UseDevelopmentStorage=true"
                    }
                  }
                  

                  这篇关于azure function c# http trigger blob output的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 Azure Functions 应用程序 blobtrigger 中设置 blob 的内容类型 下一篇:“函数运行时无法启动"

                  相关文章

                  <legend id='GbsGB'><style id='GbsGB'><dir id='GbsGB'><q id='GbsGB'></q></dir></style></legend>
                    <i id='GbsGB'><tr id='GbsGB'><dt id='GbsGB'><q id='GbsGB'><span id='GbsGB'><b id='GbsGB'><form id='GbsGB'><ins id='GbsGB'></ins><ul id='GbsGB'></ul><sub id='GbsGB'></sub></form><legend id='GbsGB'></legend><bdo id='GbsGB'><pre id='GbsGB'><center id='GbsGB'></center></pre></bdo></b><th id='GbsGB'></th></span></q></dt></tr></i><div id='GbsGB'><tfoot id='GbsGB'></tfoot><dl id='GbsGB'><fieldset id='GbsGB'></fieldset></dl></div>

                    1. <small id='GbsGB'></small><noframes id='GbsGB'>

                      • <bdo id='GbsGB'></bdo><ul id='GbsGB'></ul>

                    2. <tfoot id='GbsGB'></tfoot>