jn1*_*1kk 0 c# appsettings azure azure-blob-storage azure-function-app
我需要一个 Azure Functions blob 触发器来触发应用设置在运行时提供的存储桶。我读到可以这样做:
[FunctionName("Process")]
public static async Task Process([BlobTrigger("%BucketName%/{name}", Connection = "AzureWebJobsStorage")] Stream avroBlobStream, string name, TraceWriter log)
{
}
Run Code Online (Sandbox Code Playgroud)
如果我BucketName只有Values在 appsettings.json的字段中,这在本地工作。
{
"IsEncrypted": false,
"Values": {
"BucketName": "capture-bucket",
}
}
Run Code Online (Sandbox Code Playgroud)
如果它不在 Values 字段中,则这是错误:
[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.).
Run Code Online (Sandbox Code Playgroud)
我在 Azure App 函数中设置了一个 just BucketName,但它给了我同样的错误。您能否建议在真实的 Azure 环境中实际应该调用什么设置或我做错了什么?应该是Values:BucketName吗?但我从未在 Microsoft 网站上看到过以Values:作为前缀的示例。
对于你的错误,我测试了一种情况Microsoft.Azure.WebJobs.Extensions.Storage是没有安装包。安装后,它会工作。你可以试试。
至于动态绑定,官方教程中有说明:绑定表达式-应用设置。当您在本地测试时,应用设置值来自local.settings.json文件。我不知道你为什么使用 appsettings.json。格式就是您粘贴的内容。
而在 Azure 上,local.settings.json由于 VS 中的设置不会部署,您必须转到 Azure 功能配置,并设置绑定名称。
我有测试,这样它就可以工作,它可以处理我的 blob 文件。
希望这可以帮助您,如果我误解了您的要求,请告诉我。
| 归档时间: |
|
| 查看次数: |
1751 次 |
| 最近记录: |