Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow HTTP Trigger to bind to both request and poco #273

Closed
MikeStall opened this issue Aug 18, 2017 · 7 comments
Closed

Allow HTTP Trigger to bind to both request and poco #273

MikeStall opened this issue Aug 18, 2017 · 7 comments
Assignees
Milestone

Comments

@MikeStall
Copy link
Contributor

MikeStall commented Aug 18, 2017

Support this: Azure/Azure-Functions#401

ScriptBinding has some extra binding magic to support this. That should be in the http extension instead so that it works in all cases. It currently does not work in direct SDK cases, which includes Functions VS Tooling.

@NicolasHumann
Copy link

+1 !!!
I really need this feature as well !

@TheeJamesLee
Copy link

For reference:

Assuming that you are using the HttpRequestMessage to get headers/query parameters and/or for creating the response back. If so, this will achieve what you need:

public static async Task<HttpResponseMessage> Run([HttpTrigger(...)]POCO req, IDictionary<string, string> headers, IDictionary<string, string> query)

(then just build a response back rather then using the helpers off HttpRequestMessage)

The HttpTrigger will bind the Header and Query dictionaries to the 2 dictionaries in the signature above, which is what we do for what we need.

If we need anything more detailed then we just use the main http request object and in the function deserialize the object.

@MikeStall MikeStall self-assigned this Aug 23, 2017
@christopheranderson christopheranderson added this to the Sprint 5 milestone Aug 24, 2017
@MikeStall
Copy link
Contributor Author

We need to fix this (and document it so people know about it!). Script + CSX supports it.

@MikeStall
Copy link
Contributor Author

MikeStall added a commit that referenced this issue Aug 29, 2017
Script had special logic to allow this for CSX; but VS tooling and direct SDK users didn't have the same logic. Add the httprequest binding logic in the binding.
@paulbatum paulbatum modified the milestones: Sprint 6, Sprint 5 Sep 6, 2017
MikeStall added a commit that referenced this issue Sep 7, 2017
Script had special logic to allow this for CSX; but VS tooling and direct SDK users didn't have the same logic. Add the httprequest binding logic in the binding.
MikeStall added a commit that referenced this issue Sep 8, 2017
Script had special logic to allow this for CSX; but VS tooling and direct SDK users didn't have the same logic. Add the httprequest binding logic in the binding.
@MikeStall
Copy link
Contributor Author

Resolved with #284

MikeStall added a commit that referenced this issue Sep 28, 2017
Script had special logic to allow this for CSX; but VS tooling and direct SDK users didn't have the same logic. Add the httprequest binding logic in the binding.

# Conflicts:
#	src/WebJobs.Extensions.Http/Config/HttpExtensionConfiguration.cs
#	src/WebJobs.Extensions.Http/GlobalSuppressions.cs
#	src/WebJobs.Extensions.Http/HttpTriggerAttributeBindingProvider.cs
#	src/WebJobs.Extensions.Http/WebJobs.Extensions.Http.csproj
MikeStall added a commit that referenced this issue Sep 28, 2017
@baio
Copy link

baio commented Feb 23, 2018

btw It still not working with core at the moment (

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="RegisterOrgFun.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="3.0.0-beta4" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.8" />
    <PackageReference Include="System.Configuration" Version="2.0.5" />
    <PackageReference Include="FSharp.Core" Version="4.2.3" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
    <Content Include="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </Content>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\Domain\Domain.fsproj" />
    <ProjectReference Include="..\..\Utils\Utils.fsproj" />
  </ItemGroup>

</Project>

[2/23/2018 10:21:57 PM] Reading host configuration file 'C:\dev\doer\doer-hive\DoerUsers\RegisterOrgFun\bin\Debug\netcoreapp2.0\host.json'
[2/23/2018 10:21:57 PM] Host configuration file read:
[2/23/2018 10:21:57 PM] {}
[2/23/2018 10:21:58 PM] Generating 1 job function(s)
[2/23/2018 10:21:58 PM] Starting Host (HostId=desktop5f41kfm-532994629, Version=2.0.11415.0, ProcessId=836, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
[2/23/2018 10:21:58 PM] A ScriptHost error has occurred
[2/23/2018 10:21:58 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Main.run'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'req' to type HttpRequest. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).

@ianisms
Copy link

ianisms commented Jul 26, 2019

Not working with core 2.2:

    public HttpResponseMessage CreateRoleDefinition(
        [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "roleDefinitions")]
        RoleDefinition roleDefinition,
        HttpRequestMessage req,
        ILogger log)

CreateRoleDefinition: Microsoft.Azure.WebJobs.Host: Error indexing method 'CreateRoleDefinition'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'req' to type HttpRequestMessage. 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.).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants