Comments (27)
<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.
At this moment the solution is only to downgrade to .NET Core 2.2
from azure-functions-dotnet-extensions.
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.
#8
heres the fix
from azure-functions-dotnet-extensions.
Thank you very much for your time, your solution did the trick and we got it working!
from azure-functions-dotnet-extensions.
@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.
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.
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.
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.
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.
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.
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.
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.
1.0.26
doesn't work locally for me, I'm testing it with the sample project.
from azure-functions-dotnet-extensions.
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.
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.
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"
from azure-functions-dotnet-extensions.
Same issue for me
Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
from azure-functions-dotnet-extensions.
Same here... Happening when I reference
<PackageReference Include="Microsoft.Extensions.Http" Version="3.0.0" />
from azure-functions-dotnet-extensions.
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.
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.
Is the runtime version still on preview?
https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions
from azure-functions-dotnet-extensions.
Tested locally with v3 instead of v3-preview with no success (No function runtime available)
from azure-functions-dotnet-extensions.
And this error still persist:
Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve service for type
from azure-functions-dotnet-extensions.
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.
This seems like it could also be related to Azure/azure-functions-host#5401.
from azure-functions-dotnet-extensions.
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)
- Azure function v3 fails to start up in Visual Studio 2019 for Mac when using Microsoft.Azure.Functions.Extensions.DependencyInjection HOT 8
- Could not load type 'Microsoft.Azure.WebJobs.Hosting.IWebJobsStartup2' HOT 16
- Registering implementation type X is not assignable to service type IX when using Generics HOT 6
- [FEATURE REQ] Fluent Strongly Typed Context
- [Feature] Remove local.settings.json and be consistent with how AspNet Core work HOT 1
- [Question] How to use appsetting.json values in a trigger? HOT 2
- DependencyInjection stops working when we add User Secrets (Error: "Microsoft.Extensions.DependencyInjection.Abstractions: Unable to resolve [injected service] while attempting to activate [function])
- Upgrading Microsoft.Extensions.DependencyInjection.Abstractions to latest version (5.0.0) breaks DI HOT 1
- [Feature Request] Specify Startup per function HOT 2
- Dependency Injection not instantiating instances when using function.json rather than attributes
- Url is missing from appinsights logs for requests if use FunctionStartup HOT 9
- Error during startup when using SignalR.Client HOT 1
- The Functions scale controller may not scale the following functions correctly because some configuration values were modified in an external startup class HOT 16
- [Pls Help] Why DI doesn't work as expected when using Azure Function HOT 2
- Dotnet 6 and Azure Functions V4 HOT 5
- Why is the context not available on IFunctionsHostBuilder, but on internal interface IFunctionsHostBuilderExt HOT 7
- This repo is missing important files HOT 1
- Incompatiblity with EF Core 7 HOT 11
- Is there any documentation available for migrating from IWebJobsStartup to FunctionsStartup in Azure Function? HOT 3
- Update Microsoft.Azure.WebJobs to latest, Newtonsoft.Json 11.0.2 dependency HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-functions-dotnet-extensions.