gpt4 book ai didi

azure - 将 Azure 函数作为 C# Web 应用程序进行调试

转载 作者:行者123 更新时间:2023-12-03 01:47:56 24 4
gpt4 key购买 nike

我有一个基于简单触发器的 Azure 函数,该函数连接到 Azure 事件中心,并在事件中心每次收到消息时写出一条消息。

我根据以下帖子将其创建为 C# Web 应用程序,并尝试在本地调试此功能:- https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/

这是我的函数代码:-

using Microsoft.Azure.WebJobs.Host;
using System;
using System.Threading.Tasks;

namespace FunctionLibrary
{
public class EventHubProcessorFunction
{
public static void Run(string myEventHubMessage, TraceWriter log)
{
log.Info($"C# Event Hub trigger function processed a Vineet message: {myEventHubMessage}");
}
}
}

这是我的 function.json

{
"disabled": false,
"scriptFile": ".\\bin\\FunctionAsWebApp.dll",
"entryPoint": "FunctionLibrary.EventHubProcessorFunction.Run",
"bindings": [
{
"type": "eventHubTrigger",
"name": "myEventHubMessage",
"direction": "in",
"path": "edpvineethub",
"connection": "AzureWebJobsServiceBus"
}
]
}

我的文件夹结构如下:-我已在 Web 应用程序项目中包含以下文件:-

bin\FunctionAsWebApp.dll
NameOfYourFunction\function.json
AnotherFunctionIfYouHaveOne\function.json
appsettings.json
host.json

但是,当我尝试在本地运行时收到以下错误消息;-

No job functions found. Try making your job classes and methods public. If you'r
e using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've call
ed the registration method for the extension(s) in your startup code (e.g. confi
g.UseServiceBus(), config.UseTimers(), etc.).

如有任何帮助,我们将不胜感激。

最佳答案

检查您的文件夹结构是否如下所示:

bin\FunctionAsWebApp.dll
NameOfYourFunction\function.json
AnotherFunctionIfYouHaveOne\function.json
appsettings.json
host.json

并且 function.json 当然应该相应地引用二进制文件

"scriptFile": "..\\bin\\FunctionAsWebApp.dll"

关于azure - 将 Azure 函数作为 C# Web 应用程序进行调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43589822/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com