Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Azure函数-如何传递自定义输入参数_C#_.net_Azure Functions - Fatal编程技术网

C# Azure函数-如何传递自定义输入参数

C# Azure函数-如何传递自定义输入参数,c#,.net,azure-functions,C#,.net,Azure Functions,我在将类对象作为输入参数传递给azure函数时遇到问题,正确的方法是什么?我的功能如下所示 public async Task<IActionResult> GetClinics( [HttpTrigger(AuthorizationLevel.Function, "get", Route = "clinics")] HttpRequest req, ILogger log, PersonDocument thePerson) { //

我在将类对象作为输入参数传递给azure函数时遇到问题,正确的方法是什么?我的功能如下所示

    public async Task<IActionResult> GetClinics(
        [HttpTrigger(AuthorizationLevel.Function, "get", Route = "clinics")] HttpRequest req, ILogger log, PersonDocument thePerson)
    {
        //do something
    }

最简单的解决方法是什么?我必须准备自己的定制装订吗?PersonDocument只是一个具有一些属性的类,我想从body中提取这些属性。我找到的唯一信息显示了如何添加带有自定义属性的自定义绑定,但我很好奇是否真的需要添加它们来解决这样一个简单的问题?

azure函数C#类库开发的方法签名只能包括以下内容:

用于日志记录的ILogger或TraceWriter(仅v1版本)

用于正常关机的CancellationToken参数

使用属性修饰标记输入和输出绑定

绑定表达式参数以获取触发器元数据

对于您的问题,您需要的似乎是一个输入绑定,因此请查看此文档:

您可以看到,azure函数默认只支持少数输入绑定。所以我认为如果你想实现你想要的,定制绑定是必要的

The 'GetClinics' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'GetClinics'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'thePerson' to type PersonDocument. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).