Azure/azure-functions-dotnet-extensions

get_Services method not found

ravishetty9 opened this issue ยท 33 comments

I am trying to add DI to our existing azure functions(.Net Core 2.0). Followed the steps mentioned in this link - https://docs.microsoft.com/en-us/azure/azure-functions/functions-dotnet-dependency-injection

However, I am getting the following error. Are there any other packages that I need to install or update?

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

Value cannot be null.
Parameter name: provider

Appreciate any help.

Thanks!

Getting the same error but in my case the function app is targeting .NET Core 3.0

Getting the same error but in my case the function app is targeting .NET Core 3.0

Same issue for me.

My app for my web site also already targets ASP.NET Core 3.0 and I get the exact same error message when starting up the Azure Functions. I tried setting a break point inside the Startup.Configure function to figure out why this happens. The breakpoint wasn't hit! That is probably also the reason why the get_Services() call later fails. Maybe there is an out of the box solution for dependency injection for Azure Functions which hasn't been documented yet for the new release? Or any other simple workaround? Or do we now have to skip using dependency injection for Azure Functions? Until I have both the web site and the Azure Functions working correctly, I am now stuck. The upgrade to VS2019 16.3.1 didn't solve the problem.

Looks like this error is connected to Microsoft.Extensions.DependencyInjection 3.0.0.

Looks like this error is connected to Microsoft.Extensions.DependencyInjection 3.0.0.

It may just be a matter of figuring out exactly which packages with which versions are needed to get this to work. After some experimenting I gave up for now. It seems to be an undocumented breaking change...

If you look at the Azure CLI package references (found at %LocalAppData%\AzureFunctionsTools\Releases\{version}\cli on Windows), you can see that the version of Microsoft.Extensions.DependencyInjection.dll is still <= 2.2.

This is the DLL that is used by the local CLI tools to create and inject the IServiceProvider that is part of the IWebHostBuilder (as seen here), and I can't imagine the runtime in Azure itself is going to be much different from a dependency perspective. It looks like the problem will exist until the the AzureFunction runtime itself is updated, which will hopefully happen sooner than later.

@jonathanjuras Thanks, that is roughly what I assumed was going on. I hoped to get it working by using some older Nuget packages, but then I can also forget about the advantages of moving to ASP.NET Core 3.0 in my web app as I share some code between the web app and the Azure Functions. I hope for a working preview version soon, so that I can continue using the Azure Functions as they worked with ASP.NET Core 2.2. October isn't far away anyhow. It is clear that the ASP.NET Core 3.0 and all its dependencies weren't quite ready in time, after following the DotNetConf 2019 sessions,, that is why already version 3.1 is planned, to fix all issues causing problems in 3.0.

So I tried to test what exactly is wrong and find out something really strange:

Console.WriteLine(typeof(IWebJobsBuilder).AssemblyQualifiedName);
Console.WriteLine(typeof(IWebJobsBuilder).GetProperty("Services").PropertyType.AssemblyQualifiedName);
Console.WriteLine(typeof(IServiceCollection).AssemblyQualifiedName);

Returns:

Microsoft.Azure.WebJobs.Host.WebJobsBuilder, Microsoft.Azure.WebJobs.Host, Version=3.0.13.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Microsoft.Extensions.DependencyInjection.IServiceCollection, Microsoft.Extensions.DependencyInjection.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
Microsoft.Extensions.DependencyInjection.IServiceCollection, Microsoft.Extensions.DependencyInjection.Abstractions, Version=3.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60

Listing assemblies:
AppDomain.CurrentDomain.GetAssemblies()
also returns Microsoft.Extensions.DependencyInjection.Abstractions loaded twice.

So Azure Function Runtime is injecting packages 2.2 regardless of referenced 3.0 and that is why it's causing run-time type mismatch and Method Not found exceptions.

axm commented

Edit: I updated the Basic.csproj file to show a breaking function. The issue is introduced by the addition of Microsoft.Extensions.Http@3.0.0

https://github.com/axm/azure-functions-dotnet-extensions/blob/master/src/samples/DependencyInjection/Basic/Basic.csproj

I am also facing this issue, is there anything that can be done about it or am I going to have to wait until Azure Functions is updated to Microsoft.Extensions.DependencyInjection.Abstractions 3.0.0?

Edit: After some investigation, I found I had a project somehwhere in my solution that required v3.0.0 after changing that to require >=2.2.0 the issue was resolved and my class libraries now work in both netcore3.0 and Azure Functions v2.

oddly I'm getting this on a mac (using vscode) but not on 2 windows machines (vscode & vs2019). I'm experiencing this in Azure Functions with the Durable Functions preview 2.2.0-beta.

UPDATE: and 5 minutes later, finally solved. The mac was using azure-functions-tools 2.0.3. I had to do brew upgrade to get the latest version.

oddly I'm getting this on a mac (using vscode) but not on 2 windows machines (vscode & vs2019). I'm experiencing this in Azure Functions with the Durable Functions preview 2.2.0-beta.

UPDATE: and 5 minutes later, finally solved. The mac was using azure-functions-tools 2.0.3. I had to do brew upgrade to get the latest version.

It didn't solve my problem. I just need to get the dependency injection to work as described in the beginning of the thread. Would you please share with us more details on exactly which libraries you are including and your configuration settings?

By reading this Azure/app-service-announcements-discussions#115 I figured out that if you reference any .NET Core 3 packages in your function project (event if the project is .NET Core 3) dependency injection will not work and you will have problems. When I removed my 3.0 assemblies the function started working again.

@bpellkvist I ran into this issue a short time ago and I can confirm (for me) it was caused by the latest version of Microsoft.Extensions.Http 3.x causing me grief. I was specifically adding the Http Factor Service (AddHtpClient).

Seeing some 3.x version issues in general I ran dotnet add package Microsoft.Extensions.Http -v 2.20 instead of going with the latest (3.x) and my issue was resolved (same error as you reported). We're obviously running into some assembly versioning issues as various dependencies start their transition to .net core 3.0.

Hopefully this resolves your issue.

I'm having this issue, as well, and my project has no "3.0" assemblies referenced as far as I can tell. I do have a custom assembly referenced which targets 3.0, as does the Function project itself, but the comments above seem to imply that shouldn't be the problem.

Any ideas where to look? Also, how does one determine whether a reference is a ".NET Core 3 package", anyway?

@jamie-tillman I think you might have misinterpreted some of the above comments. Functions V2 currently runs on .NET Core 2.2, so you'll likely run into problems if your function app code is targeting .NET Core 3.0 (or referencing assemblies that target .NET Core 3.0).

As folks on this issue have already referenced, there is a Functions 3.x release coming that will allow you to target .NET Core 3.0.

In the meantime, check your references for any Microsoft.Extensions.* packages that have been bumped to 3.0.0. You'll need to downgrade them to 2.2.0.

As @paulbatum mentioned above, Azure Functions 2.0 is not compatible with .NET Core 3.0 (runtime and dependencies)

We will have a preview that will bring .NET Core 3.0 deployed very soon. Please keep an eye on Azure/app-service-announcements#200 for updates.

@jamie-tillman I think you might have misinterpreted some of the above comments. Functions V2 currently runs on .NET Core 2.2, so you'll likely run into problems if your function app code is targeting .NET Core 3.0 (or referencing assemblies that target .NET Core 3.0).

As folks on this issue have already referenced, there is a Functions 3.x release coming that will allow you to target .NET Core 3.0.

In the meantime, check your references for any Microsoft.Extensions.* packages that have been bumped to 3.0.0. You'll need to downgrade them to 2.2.0.

Thanks for the suggestion, but I'm not sure yet that I did misinterpret. Some folks in the comments made vague references to identifying any ".NET Core 3.0 packages" and checking my project, all I could see documented were the specific versions of the Nuget packages themselves, with no specifics as to which .NET Core version they targeted. This left me with advice I couldn't follow, hence the question. I did actually already look for Microsoft.Extensions.* v3.* specifically, and found none, so that wasn't the cause.

In the end, realizing that I have some custom assemblies that are built on .NET Core 3 which will be merged into what I'm doing making it impossible to use Azure Functions as is, I've switched to a .NET Core Worker project. It wasn't my first choice, but at least it supports the latest .NET Core version.

I'll be honest, my first foray into coding with these Azure support libraries has been nightmarish. Maybe it's crappy architecture in .NET Core, maybe it's sloppy tooling by Microsoft or Nuget. I don't know. I do know that this platform is playing too fast-and-loose with versioning for me to trust this approach for any serious programming right now. It's too easy to spend hours building something you can't use in the way you planned.

Update for anyone following this: The preview for Azure Functions 3 is out now and it resolves this issue. Here's to hoping that the production release happens quickly!

@danejur thanks for verifying this so quickly! Closing this as resolved.

Not entirely sure this issue is 100% fixed, my Functions app csproj looks as follows;

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.2" />
    <PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\SharedLib\SharedLib.csproj" />
  </ItemGroup>
</Project>

Yet I get the same error message;

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

Session Id: 805970552d7f4e73a7851071a196f31e

Timestamp: 2020-01-08T15:48:40.566Z

I fixed it in the same manner as above, one of my class libraries (a shared dependency) used the following;

<ItemGroup>
   <PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.0" />
   <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.0" />
</ItemGroup>

When I removed those dependencies DI worked as expected...

What worked for me was changing the AzureFunctions entry in my projct file from v2 to v3. It's fixed it locally for me, but still doesn't work when I deploy to azure.

My project file now looks like this

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="2.1.0" />
        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.2" />
    </ItemGroup>
    <ItemGroup>
      <ProjectReference Include="..\My.Namespace\My.Namespace.csproj" />
        ...
    </ItemGroup>
    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Update="local.settings.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
    </ItemGroup>
</Project>

All my referenced projects are netstandard2.1.

Hope that helps

What worked for me was changing the AzureFunctions entry in my projct file from v2 to v3. It's fixed it locally for me, but still doesn't work when I deploy to azure.

My project file now looks like this

<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <TargetFramework>netcoreapp3.1</TargetFramework>
        <AzureFunctionsVersion>v3</AzureFunctionsVersion>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="2.1.0" />
        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.2" />
    </ItemGroup>
    <ItemGroup>
      <ProjectReference Include="..\My.Namespace\My.Namespace.csproj" />
        ...
    </ItemGroup>
    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Update="local.settings.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
    </ItemGroup>
</Project>

All my referenced projects are netstandard2.1.

Hope that helps

I have also fixed in azure. Turns out the version of the function was also set to v2 within azure.

To change it. Open function in the azure portal. Go to the Function settings (Platform Features > General Settings > Function app settings). There should be a "runtime version" setting group which you can change the runtime from v1, v2 and v3. I set it to v3.

My project file is set to:

netcoreapp3.1 v3

Per the above and locally I still get the error:

ethod not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
Value cannot be null.
Parameter name: provider

dotnet --version: 3.1.101
func --version: 2.7.1948 (latest that I can get from Ubuntu apt based on the instructions on docs.microsoft.com, although the github site says that there is a newer version)

Just going to leave this here, as I've spent the last few hours trying to solve this myself, and found it was not code related but environment related, and to do with the azure-functions-core-tools tooling version I had being 2, rather than 3.

More details incase it helps anyone else save some time - on a Mac but I imagine it will be the same for other environments:

Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
Value cannot be null.
Parameter name: provider

Resolution is to ensure you're using version 3 of azure-functions-core-tools.

Symptoms:

...
...
> Executing task: func host start <


                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (2.7.1948 Commit hash: 29a0626ded3ae99c4111f66763f27bb9fb564103)
Function Runtime Version: 2.0.12888.0
[31/01/20 12:19:44 AM] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '7baa2e3b-434f-49b2-9162-44ec76241027'
[31/01/20 12:19:44 AM] Reading host configuration file '/Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/Debug/netcoreapp3.1/host.json'
[31/01/20 12:19:44 AM] Host configuration file read:
[31/01/20 12:19:44 AM] {
[31/01/20 12:19:44 AM]   "version": "2.0"
[31/01/20 12:19:44 AM] }
[31/01/20 12:19:44 AM] Reading functions metadata
[31/01/20 12:19:44 AM] 1 functions found
[31/01/20 12:19:44 AM] Loading startup extension 'Startup'
[31/01/20 12:19:44 AM] Loaded extension 'Startup' (1.0.0.0)
[31/01/20 12:19:45 AM] A host error has occurred during startup operation '7baa2e3b-434f-49b2-9162-44ec76241027'.
[31/01/20 12:19:45 AM] hnrgapi.functions: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
Value cannot be null.
Parameter name: provider
Application is shutting down...
[31/01/20 12:19:45 AM] Initialization cancellation requested by runtime.
Hosting environment: Production
Content root path: /Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/Debug/netcoreapp3.1
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[31/01/20 12:19:45 AM] Stopping host...
[31/01/20 12:19:45 AM] Host shutdown completed.
The terminal process terminated with exit code: 1

Resolution:

In terminal:

$ brew uninstall azure-functions-core-tools
Uninstalling /usr/local/Cellar/azure-functions-core-tools/2.7.1948... (3,018 files, 430.3MB)

$ brew install azure-functions-core-tools@3
==> Installing azure-functions-core-tools@3 from azure/functions
==> Downloading https://functionscdn.azureedge.net/public/3.0.2009/Azure.Functions.Cli.osx-x64.3.0.2009.zip
Already downloaded: /Users/leigh/Library/Caches/Homebrew/downloads/079793bf4adfc986e99e65ce1488220d696a844b83b956d65260f2f3fa329789--Azure.Functions.Cli.osx-x64.3.0.2009.zip

 Telemetry 
 --------- 
 The Azure Functions Core tools collect usage data in order to help us improve your experience.
 The data is anonymous and doesn't include any user specific or personal information. The data is collected by Microsoft.
 
 You can opt-out of telemetry by setting the FUNCTIONS_CORE_TOOLS_TELEMETRY_OPTOUT environment variable to '1' or 'true' using your favorite shell.
๐Ÿบ  /usr/local/Cellar/azure-functions-core-tools@3/3.0.2009: 3,125 files, 457.1MB, built in 22 seconds

The running in Code:

> Executing task: func host start <


                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (3.0.2009 Commit hash: 77395527a4e9c28da8400dcfd1a450f4e0d0c36c)
Function Runtime Version: 3.0.12930.0
[31/01/2020 12:26:13 AM] FUNCTIONS_WORKER_RUNTIME set to dotnet. Skipping WorkerConfig for language:python
[31/01/2020 12:26:13 AM] FUNCTIONS_WORKER_RUNTIME set to dotnet. Skipping WorkerConfig for language:java
[31/01/2020 12:26:13 AM] FUNCTIONS_WORKER_RUNTIME set to dotnet. Skipping WorkerConfig for language:powershell
[31/01/2020 12:26:13 AM] FUNCTIONS_WORKER_RUNTIME set to dotnet. Skipping WorkerConfig for language:node
[31/01/2020 12:26:14 AM] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '7453a75f-75b7-4ce1-81a5-2d689e456165'
[31/01/2020 12:26:14 AM] Reading host configuration file '/Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/Debug/netcoreapp3.1/host.json'
[31/01/2020 12:26:14 AM] Host configuration file read:
[31/01/2020 12:26:14 AM] {
[31/01/2020 12:26:14 AM]   "version": "2.0"
[31/01/2020 12:26:14 AM] }
[31/01/2020 12:26:14 AM] Reading functions metadata
[31/01/2020 12:26:15 AM] 1 functions found
[31/01/2020 12:26:15 AM] Loading startup extension 'Startup'
[31/01/2020 12:26:16 AM] Loaded extension 'Startup' (1.0.0.0)
...
...
Hosting environment: Production
Content root path: /Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/Debug/netcoreapp3.1
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.

Http Functions:

        HttpTriggerCSharp: [GET,POST] http://localhost:7071/api/HttpTriggerCSharp

[31/01/2020 12:26:23 AM] Host lock lease acquired by instance ID '000000000000000000000000CC08CB69'.

@JohnGalt1717 try updating your version of azure-function-core-tools to v3+.

For my project - v2:

$ func --version    
2.7.1948

$ func start
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 45.05 ms for /Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/hnrgapi.functions.csproj.
  hnrgapi.functions -> /Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/output/bin/hnrgapi.functions.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.37



                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (2.7.1948 Commit hash: 29a0626ded3ae99c4111f66763f27bb9fb564103)
Function Runtime Version: 2.0.12888.0
[31/01/20 12:58:44 AM] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: 'd397fb50-906e-40ec-97f9-84ee2aad0a14'
[31/01/20 12:58:44 AM] Reading host configuration file '/Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/output/host.json'
[31/01/20 12:58:44 AM] Host configuration file read:
[31/01/20 12:58:44 AM] {
[31/01/20 12:58:44 AM]   "version": "2.0"
[31/01/20 12:58:44 AM] }
[31/01/20 12:58:44 AM] Reading functions metadata
[31/01/20 12:58:44 AM] 1 functions found
[31/01/20 12:58:44 AM] Loading startup extension 'Startup'
[31/01/20 12:58:44 AM] Loaded extension 'Startup' (1.0.0.0)
[31/01/20 12:58:45 AM] A host error has occurred during startup operation 'd397fb50-906e-40ec-97f9-84ee2aad0a14'.
[31/01/20 12:58:45 AM] hnrgapi.functions: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
Value cannot be null.
Parameter name: provider
Application is shutting down...
[31/01/20 12:58:45 AM] Initialization cancellation requested by runtime.
Hosting environment: Production
Content root path: /Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/output
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[31/01/20 12:58:45 AM] Stopping host...
[31/01/20 12:58:45 AM] Host shutdown completed.

v3:

$ func --version    
3.0.2009

$ func start
Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restore completed in 50.59 ms for /Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/hnrgapi.functions.csproj.
  hnrgapi.functions -> /Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/output/bin/hnrgapi.functions.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:02.99



                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %

Azure Functions Core Tools (3.0.2009 Commit hash: 77395527a4e9c28da8400dcfd1a450f4e0d0c36c)
Function Runtime Version: 3.0.12930.0
[31/01/2020 1:01:25 AM] FUNCTIONS_WORKER_RUNTIME set to dotnet. Skipping WorkerConfig for language:python
[31/01/2020 1:01:25 AM] FUNCTIONS_WORKER_RUNTIME set to dotnet. Skipping WorkerConfig for language:java
[31/01/2020 1:01:25 AM] FUNCTIONS_WORKER_RUNTIME set to dotnet. Skipping WorkerConfig for language:powershell
[31/01/2020 1:01:25 AM] FUNCTIONS_WORKER_RUNTIME set to dotnet. Skipping WorkerConfig for language:node
[31/01/2020 1:01:25 AM] Building host: startup suppressed: 'False', configuration suppressed: 'False', startup operation id: '19f10587-4797-4efe-b596-be7bc79ab6b0'
[31/01/2020 1:01:25 AM] Reading host configuration file '/Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/output/host.json'
[31/01/2020 1:01:25 AM] Host configuration file read:
[31/01/2020 1:01:25 AM] {
[31/01/2020 1:01:25 AM]   "version": "2.0"
[31/01/2020 1:01:25 AM] }
[31/01/2020 1:01:26 AM] Reading functions metadata
[31/01/2020 1:01:26 AM] 1 functions found
[31/01/2020 1:01:26 AM] Loading startup extension 'Startup'
[31/01/2020 1:01:27 AM] Loaded extension 'Startup' (1.0.0.0)
...
...
[31/01/2020 1:01:28 AM] Job host started
Hosting environment: Production
Content root path: /Users/leigh/dev/hnrg/apirepo/hnrgapi.functions/bin/output
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.

Http Functions:

	HttpTriggerCSharp: [GET,POST] http://localhost:7071/api/HttpTriggerCSharp

[31/01/2020 1:01:33 AM] Host lock lease acquired by instance ID '000000000000000000000000CC08CB69'.

You can't on Linux:

apt-cache policy azure-functions-core-tools
[sudo] password for jhancock:
azure-functions-core-tools:
Installed: 2.7.1948-1
Candidate: 2.7.1948-1
Version table:
*** 2.7.1948-1 100
100 /var/lib/dpkg/status

As far as I can tell there's no way of grabbing it. Considering doing a manual install. The instructions don't tell you how to get the v3 release either, which I put in a ticket for too.

So I hack this. IF you download the zip file you can extract it into a directory and then do the following:

sudo cp -r ./* /lib/azure-functions-core-tools/

This should overwrite all of the files that are in there and then func --v should give you 3.0.2009 I believe and then everything is right with the world.

But the Azure Functions team needs to have betas in a .deb somewhere so that we can subscribe to both and get the latest version or the version we want and not have to manually do this.

It sounds like there is a packaging issue with core tools being discussed here? If so we probably need to move this conversation to a new issue in https://github.com/Azure/azure-functions-core-tools

@ahmelsayed can you take a look at the above discussion?

v3 is only available on npm with @preview and homebrew with @3, but not on choco or APT sources yet. I think @ankitkumarr and @yojagad were waiting on the release until other tooling/ux updates but I'm not too sure about the current status. We can follow up on the core tools repo Paul linked to above

@ahmelsayed That's the problem. None of that works for Linux and there is no way to get preview releases on linux. They need to address this and get a plan for how to install preview releases on linux without having to manually do it.

Just posting a clunky workaround until this gets fixed if you need v3 on Linux - posted as an earlier comment on a thread between @JohnGalt1717 and me:

TL;DR

apt-get update
apt-get install -y wget unzip
wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
apt-get update
apt-get install -y dotnet-runtime-3.1
wget https://github.com/Azure/azure-functions-core-tools/releases/download/3.0.2009/Azure.Functions.Cli.linux-x64.3.0.2009.zip
unzip -d azure-functions-cli Azure.Functions.Cli.linux-x64.3.0.2009.zip
cd azure-functions-cli
chmod +x func
./func

Slightly longer version:
#32 (comment)

If you encountered this issue when running an azure function project from VS2019 Community on MacOS, that because the AzureFunctionTools that is shipped with VS2019CE still stay in v2.

You need to replace azure-functions-cli by one of its v3

The path as following (in Finder)

visualstudio > package content > resource > monodevelop > Addins > MonoDevelop.AzureFunctions > azure-functions-cli

Backup that folder first, then clean its content, then copy over the v3 of azure-functions-cli into it.

You can download the azure-functions-cli from:
https://functionscdn.azureedge.net/public/3.0.2245/Azure.Functions.Cli.osx-x64.3.0.2245.zip

as is described in the AzureFunctionTools's feed

https://functionscdn.azureedge.net/public/cli-feed-v3.json

"3.4.1": {
"Microsoft.NET.Sdk.Functions": "3.0.1",
"cli": "https://functionscdn.azureedge.net/public/3.0.2245/Azure.Functions.Cli.min.win-x86.3.0.2245.zip",
"sha2": "bded8b114078a7e7751fd9e9eeff1148453fb1f29e66bfe123fd4d257aa4e8a9",
"nodeVersion": "~12",
"localEntryPoint": "func.exe",
"itemTemplates": "https://www.nuget.org/api/v2/package/Microsoft.Azure.WebJobs.ItemTemplates/3.1.1528",
"projectTemplates": "https://www.nuget.org/api/v2/package/Microsoft.Azure.WebJobs.ProjectTemplates/3.1.1528",
"templateApiZip": "https://functionscdn.azureedge.net/public/TemplatesApi/3.0.10405.zip",
"extensionBundle": {
"hostConfig": {
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
},
"FUNCTIONS_EXTENSION_VERSION": "~3",
"requiredRuntime": ".NET Core",
"minimumRuntimeVersion": "3.1",
"standaloneCli": [
{
"OS": "Linux",
"Architecture": "x64",
"downloadLink": "https://functionscdn.azureedge.net/public/3.0.2245/Azure.Functions.Cli.linux-x64.3.0.2245.zip",
"sha2": "5afd2c925a6ff4e63fa8cc57a07be2e2146e2193bbcc4fc086dc966e246c9dce"
},
{
"OperatingSystem": "MacOS",
"Architecture": "x64",
"downloadLink": "https://functionscdn.azureedge.net/public/3.0.2245/Azure.Functions.Cli.osx-x64.3.0.2245.zip",
"sha2": "1f2757b249e79c7b6e2dca0c5a04b5cec438147e7db33729cc5bb896f38927bc"
},
{
"OS": "Windows",
"Architecture": "x64",
"downloadLink": "https://functionscdn.azureedge.net/public/3.0.2245/Azure.Functions.Cli.min.win-x64.3.0.2245.zip",
"sha2": "55d6c392e48bed7e6add4132b08f583e51c196b133a1ca7955374e8900e119eb"
},
{
"OS": "Windows",
"Architecture": "x86",
"downloadLink": "https://functionscdn.azureedge.net/public/3.0.2245/Azure.Functions.Cli.win-x86.3.0.2245.zip",
"sha2": "150205ed95fa6afe545e7620bdf63acc5ef0991f30a4ca9dd93b44f06b955b15"
}
]
}