BorisWilhelms / azure-function-dependency-injection

Dependency Injection for Azure Functions v2
https://blog.wille-zone.de/
MIT License
145 stars 45 forks source link

Binding Issue with Extension prevents Function indexing #34

Closed SpicySyntax closed 5 years ago

SpicySyntax commented 5 years ago

I am using the version 1.0.1 of this Nuget package in my .NET Core V2 Azure Function App to help with dependency injection and am running into an issue.

My Function app is to allow an HTTP upload of an image, and write it to blob storage and some associated meta-data to CosmosDb using the MongoDb Driver. I setup the WebJobStartup.cs class and used the '[Inject]' attribute on the interfaces I was trying to inject into the UploadFile.cs function class's Run method. See the source code.

When I run my function I get the following error:

[3/26/2019 1:34:03 PM] Error indexing method 'UploadImage' [3/26/2019 1:34:03 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'UploadImage'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'cosmosDbClient' to type ICosmosDbClient. 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.).

Is there more that I should be doing with WebJobStartup.cs? Another obvious issue with my program? Or an issue with this project itself?

SpicySyntax commented 5 years ago

I am closing this because I found a solution to fix the binding issue in my .csproj I changed `

netcoreapp2.2
<AzureFunctionsVersion>V2</AzureFunctionsVersion>

To:

netstandard2.0
<AzureFunctionsVersion>v2</AzureFunctionsVersion>

`