[英]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.