c# - Azure 函数 - function.json 它位于何处?

标签 c# azure-functions

我可以在网上看到在 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/

相关文章:

c# - 即使光标在 Canvas 之外,也会调用 MouseMove 事件。 `Border` Canvas 周围没有工作

python - Azure Function App/保存到 Blob 问题 (Python)

Azure Functions,nuget 包安装失败

C# - foreach 表现出奇怪的行为/工作没有问题

c# - 如何在 ASP.NET Core 中添加 Mime 类型

c# - 如何刷新 Windows 窗体控件的简单绑定(bind)?

c# - 选择“与 PHP 相同”时更改 MySQL C# 默认日期格式

Azure 函数无法正常工作 VS2017

c# - 作为单独实例运行的单例 Azure 函数

c# - 处理作为独立进程运行的 zip 文件 Azure 函数