将Azure函数作为C#Web应用程序进行调试 [英] Debugging Azure function as a C# Web Application
问题描述
我有一个基于触发器的简单Azure函数,该函数连接到Azure事件中心,并且每次在事件中心上收到一条消息时都会写出一条消息.
I have a simple trigger based Azure function which connects to an Azure event hub and writes out a message each time one is received on the event hub.
我根据以下帖子将其创建为C#Web应用程序,并尝试在本地调试此功能:- https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/
I created this as a C# Web Application based on the below post and am trying to debug this function locally:- 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
Here is my function.json
{
"disabled": false,
"scriptFile": ".\\bin\\FunctionAsWebApp.dll",
"entryPoint": "FunctionLibrary.EventHubProcessorFunction.Run",
"bindings": [
{
"type": "eventHubTrigger",
"name": "myEventHubMessage",
"direction": "in",
"path": "edpvineethub",
"connection": "AzureWebJobsServiceBus"
}
]
}
我的文件夹结构如下:-我在Web应用程序项目中包含以下文件:-
My folder structure is as below:-I have included the following files in the web application project:-
bin\FunctionAsWebApp.dll
NameOfYourFunction\function.json
AnotherFunctionIfYouHaveOne\function.json
appsettings.json
host.json
但是,当我尝试在本地运行时,出现以下错误消息;-
However I am getting the below error message when trying to run locally;-
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.).
任何帮助将不胜感激.
推荐答案
检查您的文件夹结构看起来像这样:
Check that your folder structure looks like this:
bin\FunctionAsWebApp.dll
NameOfYourFunction\function.json
AnotherFunctionIfYouHaveOne\function.json
appsettings.json
host.json
function.json
当然应该相应地引用二进制文件
And function.json
should of course reference the binary accordingly
"scriptFile": "..\\bin\\FunctionAsWebApp.dll"
这篇关于将Azure函数作为C#Web应用程序进行调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!