简体   繁体   English

Azure Functions Blob触发器动态绑定

[英]Azure Functions Blob Trigger Dynamic Binding

I need an Azure Functions blob trigger to trigger off a bucket that is given at runtime by an app setting. 我需要一个Azure Functions Blob触发器来触发运行时由应用程序设置提供的存储桶。 I read it is possible to do this: 我读到有可能这样做:

[FunctionName("Process")]
public static async Task Process([BlobTrigger("%BucketName%/{name}", Connection = "AzureWebJobsStorage")] Stream avroBlobStream, string name, TraceWriter log)
{
}

This works locally if I have BucketName ONLY in the Values field in appsettings.json. 如果我在BucketName的“ Values字段中只有BucketName ,则此操作在本地可用。

{
  "IsEncrypted": false,
  "Values": {
    "BucketName": "capture-bucket",
  }
}

If its not in Values field, this is the error: 如果它不在“值”字段中,则为错误:

[6/24/2019 5:52:15 PM] Function 'SomeClass.Process' failed indexing and will be disabled.
[6/24/2019 5:52:15 PM] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

I put into Azure App function a setting with just BucketName , but it gave me the same error. 我将仅BucketName的设置放入Azure App函数中,但这给了我同样的错误。 Could you suggest what the setting should be called or what I am doing wrong when actually in a real Azure environment? 当在实际的Azure环境中时,您能否建议应该调用该设置或我做错了什么? Should it be Values:BucketName ? 应该是Values:BucketName吗? But I have never seen an example on Microsoft website with Values: as the prefix. 但是我从未在Microsoft网站上看​​到以Values:作为前缀的示例。

For your error, I have a test one situation is the Microsoft.Azure.WebJobs.Extensions.Storage package is not installed. 对于您的错误,我进行了测试,一种情况是未安装Microsoft.Azure.WebJobs.Extensions.Storage程序包。 After installation, it will work. 安装后,它将正常工作。 You could have a try. 你可以试试看。

As for the dynamic bindings, the there is a description on the official tutorial: Binding expressions - app settings . 至于动态绑定,官方教程中有一个描述: 绑定表达式-app settings And when you test locally, app setting values come from the local.settings.json file. 当您在本地测试时,应用设置值来自local.settings.json文件。 I don't know why you are using appsettings.json. 我不知道您为什么使用appsettings.json。 The format is just what you paste. 格式就是您粘贴的格式。

And on Azure, cause the settings in local.settings.json won't be deployed with VS, you have to go to you Azure Function Configuration, and set the the binding name. 在Azure上,由于local.settings.json的设置不会随VS一起部署,因此您必须转到Azure Function Configuration,然后设置绑定名称。

在此处输入图片说明

在此处输入图片说明

I have test, this way it will work, it could process my blob file. 我已经测试过,这种方式可以正常工作,可以处理我的Blob文件。

在此处输入图片说明

Hope this could help you, if I misunderstand you requirements please let me know. 希望这对您有所帮助,如果我误解了您的要求,请告诉我。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure功能blob输入与servicebus触发器绑定 - Azure Function blob input binding with a servicebus trigger Azure Functions Blob 触发器 - 并发 blob - Azure Functions Blob Trigger - Concurrent blobs Azure function HTTP 触发器 Blob 存储 Z78E6221F6393D14356681DB3ZD8 绑定 - Azure function HTTP trigger Blob storage output binding Azure function 与 HTTP 触发器和 blob Z78E6221F6393D1356681DB3D 绑定失败,详细信息为 F046681DB3D9 - Azure function with HTTP trigger and blob output binding failed with 500 and no details Azure 功能:为新事件配置blob触发器 - Azure Functions: configure blob trigger only for new events Azure Functions Blob 触发器不会处理所有 Blob - Azure Functions Blob Trigger doesn't process all blobs Azure功能blob绑定 - Azure Function blob binding Azure blob 触发器未触发? - Azure blob trigger not firing? Azure 功能:在 Http 触发器和 Blob 触发器之间具有 CorrelationId 以遵循请求 - Azure Functions: Have a CorrelationId between Http Trigger and Blob Trigger to follow a request Microsoft.Azure.Functions.Worker.Diagnostics.Exceptions.FunctionInputConverterException while processing a blob trigger in Azure Function .net 5 - Microsoft.Azure.Functions.Worker.Diagnostics.Exceptions.FunctionInputConverterException while processing a blob trigger in Azure Function .net 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM