Coder Social home page Coder Social logo

Comments (27)

arkiaconsulting avatar arkiaconsulting commented on September 15, 2024 3
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0" />

is out.

Still

Microsoft.Azure.Functions.Extensions: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.WebJobs.IWebJobsBuilder.get_Services()'.

EDIT: I got rid of the exception above by downgrading all Microsoft.Extensions.* to 3.0.1

from azure-functions-dotnet-extensions.

apavelm avatar apavelm commented on September 15, 2024 2

At this moment the solution is only to downgrade to .NET Core 2.2

from azure-functions-dotnet-extensions.

worleywa7 avatar worleywa7 commented on September 15, 2024 1

Looks like we're back to the drawing board:

'The function runtime is unable to start. Functions: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
Session Id: ~~~~~

Timestamp: 2019-05-16T15:13:38.648Z'

from azure-functions-dotnet-extensions.

bentmar avatar bentmar commented on September 15, 2024

#8
heres the fix

from azure-functions-dotnet-extensions.

worleywa7 avatar worleywa7 commented on September 15, 2024

Thank you very much for your time, your solution did the trick and we got it working!

from azure-functions-dotnet-extensions.

bentmar avatar bentmar commented on September 15, 2024

@worleywa7 Just curious, have you tried publishing a function with DI to azure?

Mine works locally, but crashes instantly in the cloud with a DependencyIncetion error..

from azure-functions-dotnet-extensions.

bentmar avatar bentmar commented on September 15, 2024

Okay, let the randomness begin..

1.0.27 and 1.0.28 doesnt work in azure for dependency resolution, BUT 1.026 does.

And when downgradig to 1.0.26 it suddenly works locally aswell!

from azure-functions-dotnet-extensions.

worleywa7 avatar worleywa7 commented on September 15, 2024

Looks like we're getting the same issue as well; wasn't readily apparent until now. We're going to downgrade as well; see what we come up with.

from azure-functions-dotnet-extensions.

worleywa7 avatar worleywa7 commented on September 15, 2024

I downgraded back to 1.0.26 and things returned to throwing the DI errors...I'm going to try 1.0.28.

I take it back, not trying 1.0.28.

from azure-functions-dotnet-extensions.

worleywa7 avatar worleywa7 commented on September 15, 2024

So we did what you said at first, and it worked; that's why I closed the ticket.. I saw exactly what I wanted to see in my project. However, since then, I added nugets from two .NET Standard libraries, injected a dependency from one of those libraries, and have created functions that rely on this DIs.

from azure-functions-dotnet-extensions.

antichaosdb avatar antichaosdb commented on September 15, 2024

I tried the scopes sample - no other references. As provided with 1.0.26 it failed locally and on Azure. With Dependencies updated (1.0.28) it runs locally but when deployed to Azure I get :
Unable to resolve service for type 'Microsoft.Azure.Functions.Samples.DependencyInjectionScopes.MyServiceA' while attempting to activate 'Microsoft.Azure.Functions.Samples.DependencyInjectionScopes.SampleFunction'.

Is there a way to do some logging in the startup function so we can see if it being run when deployed?

from azure-functions-dotnet-extensions.

worleywa7 avatar worleywa7 commented on September 15, 2024

So what it ended up being was, for me at least, there was a dependency that I forgot to inject. There was a single "Object cannot be null" line in a log on the azure portal that seemed to be the issue. We're back to running our functions on 1.0.28 in the Cloud.

from azure-functions-dotnet-extensions.

jedjohan avatar jedjohan commented on September 15, 2024

The only way to get DI to work for me when deployed to Azure is using 1.0.26.

1.0.26, 1.0.27, 1.0.28 all works fine local

from azure-functions-dotnet-extensions.

eliashdezr avatar eliashdezr commented on September 15, 2024

1.0.26 doesn't work locally for me, I'm testing it with the sample project.

from azure-functions-dotnet-extensions.

antichaosdb avatar antichaosdb commented on September 15, 2024

Finally got this working. According to [(https://github.com/Azure/azure-functions-host/issues/3386#issuecomment-497492442)] the suggestion to add a reference to ExtensionsMetadataGenerator is bad. Remove this reference if you have it.

from azure-functions-dotnet-extensions.

ErikAndreas avatar ErikAndreas commented on September 15, 2024

1.0.29 not working, same issue as described in #14 (closed due to author moving on to Aws Lambda...)

Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type '...' while attempting to activate '...'

from azure-functions-dotnet-extensions.

itorian avatar itorian commented on September 15, 2024

That's totally fine for me on development and production when I create new project, but same error when i try to add DI in existing project/solution.

So why this error in existing project/solution, that's discussed here dotnet/extensions#1718

Here's my working project configurations:

  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.29" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
  </ItemGroup>

Notice i'm using, function v2, netcoreapp3.0, Sdk.Function 1.0.29 and Function.Extension 1.0.0.

Sample project here https://github.com/itorian/AzureFunctionDISample, if you running this sample please update AzureWebJobsStorage in local.settings.json or use emulator "AzureWebJobsStorage": "UseDevelopmentStorage=true"

image

from azure-functions-dotnet-extensions.

apavelm avatar apavelm commented on September 15, 2024

Same issue for me

Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.

from azure-functions-dotnet-extensions.

robertracz avatar robertracz commented on September 15, 2024

Same here... Happening when I reference

<PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />

from azure-functions-dotnet-extensions.

dacris avatar dacris commented on September 15, 2024

I had the same issue today. I removed some Nuget packages and added a namespace declaration to my Startup.cs and the problem was fixed. Using SDK 1.0.29. Not sure if this matters, but check if your Startup class has a namespace.

from azure-functions-dotnet-extensions.

eliashdezr avatar eliashdezr commented on September 15, 2024

I'm on the same boat, these combinations of NuGet versions are not working:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
    <LangVersion>latest</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
    <PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0-preview2" />
    <PackageReference Include="Utf8Json" Version="1.3.7" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

Error is
Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type

from azure-functions-dotnet-extensions.

eliashdezr avatar eliashdezr commented on September 15, 2024

Is the runtime version still on preview?

https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions

from azure-functions-dotnet-extensions.

arkiaconsulting avatar arkiaconsulting commented on September 15, 2024

Tested locally with v3 instead of v3-preview with no success (No function runtime available)

from azure-functions-dotnet-extensions.

eliashdezr avatar eliashdezr commented on September 15, 2024

And this error still persist:
Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type

from azure-functions-dotnet-extensions.

coolhome avatar coolhome commented on September 15, 2024

I had issues when using preview without having visual studio 16.4 preview installed & preview environment variable enabled. Maybe try installing visual studio 16.4 with the official release nuget?

old ref: https://dev.to/azure/develop-azure-functions-using-net-core-3-0-gcm

Here is my sample csproj that I had it working with locally during preview.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.5" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.0.2" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.10" />
    <PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0-preview1" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
  </ItemGroup>
</Project>

from azure-functions-dotnet-extensions.

wtt235-bh avatar wtt235-bh commented on September 15, 2024

This seems like it could also be related to Azure/azure-functions-host#5401.

from azure-functions-dotnet-extensions.

fabiocav avatar fabiocav commented on September 15, 2024

Closing this issue as there is a mix of different problems tracked here, and they should be resolved with the release of Azure Functions 3.0 (many of the issues here are related to running on Azure Functions 2.0 while targeting .NET Core 3.0).

If you continue to have issues, please open a new issue with details and we'll investigate them. Thank you!

from azure-functions-dotnet-extensions.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.