我可以在网上看到在 function.json 文件中配置了绑定(bind)。我在 Visual Studio 中创建了一个 Azure Function 项目,我可以看到文件是在 out 文件夹中生成的。但这不是我项目的一部分。想法是将其添加到 local.settings.json 文件中,然后 Visual Studio 从那里获取它以生成文件(包括部署)?或者我应该在哪里添加绑定(bind)?似乎有点奇怪,我希望 local.settings.json 是一个不会部署到 Azure 的文件。
最佳答案
如果您使用已编译的 C# 类库函数,则构建过程会创建 function.json
(查看 bin 目录)
见这里:https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#functions-class-library-project
The build process creates a function.json file for each function. This function.json file is not meant to be edited directly. You can't change binding configuration or disable the function by editing this file. To learn how to disable a function, see How to disable functions.
使用属性(see here)配置绑定(bind)
[FunctionName("ServiceBusQueueTriggerCSharp")]
public static void Run(
[ServiceBusTrigger("myqueue", AccessRights.Manage, Connection = "ServiceBusConnection")]
string myQueueItem,
Int32 deliveryCount,
DateTime enqueuedTimeUtc,
string messageId,
[Blob("sample-images-md/{name}", FileAccess.Write, Connection = "StorageConnectionAppSetting")] Stream outputBlob)
ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
log.LogInformation($"EnqueuedTimeUtc={enqueuedTimeUtc}");
log.LogInformation($"DeliveryCount={deliveryCount}");
log.LogInformation($"MessageId={messageId}");
//now store something to outputBlob
}
StorageConnectionAppSetting
在配置中定义。对于本地,这是 local.settings.json
关于c# - Azure 函数 - function.json 它位于何处?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54594147/