Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

Runtime V2 comes with missing and wrong assemblies

Open dersia opened this issue 8 years ago • 42 comments

I just realized that running a V2 function ends up with bunch of errors.

the runtime is complaining about missing assembly Microsoft.AspNetCore.Mvc.Abstractions After checkoing %LOCALAPPDATA%\Azure.Functions.V2.Cli\2.0.1-beta I could confirm that the assembly was indeed missing.

After bringing in the assembly in version 2.0.1 it finally could find the assembly and was happy, until it tried to load Microsoft.AspNetCore.Http.Abstraction. Checkingfor that assembly I saw that it is there, but in version 2.0.0 and the runtime was looking for version 2.0.1 after fixing this, I had to do the same for all Microsoft.AspNetCore.Http.* packages.

After updating everything it finally went through fine.

dersia avatar Dec 13 '17 03:12 dersia

after going on, I realized, that there is much more effected by this. All the AspNetCore and Mvc and EFCore etc packages need to be updated to version 2.0.1.

This is due to my update to Microsoft.NET.Sdk.Functions to version 1.0.7 which is the latest. It hase a dependency to Microsoft.Azure.WebJobs version 3.0.0-beta4 which has a dependency to versions 2.0.1 of all the AspNetCore packages.

Is code of the runtime anywhere available? I'd love to contribute to the runtime and do the update to the latest WebJobs version

dersia avatar Dec 13 '17 05:12 dersia

Have you tried building and running the function locally? The tools, templates and CLI all need to be in sync. When you build and run the function locally, it should attempt to fetch all the new dependencies required.

justcla avatar Dec 13 '17 06:12 justcla

Sorry for the confusion, I'm running this locally.

dersia avatar Dec 13 '17 07:12 dersia

OK. I'll look into it. I'm on PST so you probably won't hear anything for another 12 hours.

justcla avatar Dec 13 '17 07:12 justcla

Lol I'm pst too, so it's fine.

If I stay with 1.0.6 everything is fine. I'm wondering, if this is an issue when running once and then updating. I'll investigate too and provide more info tomorrow.

Good night!

dersia avatar Dec 13 '17 08:12 dersia

Advice from engineering:

The template that ships in VS still targets 1.0.6 version. In this case the user has manually updated the version to 1.0.7 –

This is due to my update to Microsoft.NET.Sdk.Functions to version 1.0.7

Sounds like you should stick with 1.0.6 :-)

justcla avatar Dec 13 '17 19:12 justcla

The code for the runtime is available at https://github.com/Azure/azure-webjobs-sdk-script

patricklee2 avatar Dec 13 '17 19:12 patricklee2

Do you see this behavior if you run the runtime standalone (without the CLI)? This could be a CLI issue as the runtime itself keeps up with the SDK updates and dependencies. I'll take a look at your scenario, but the code is where @patricklee2 pointed you to and should have expected assembly references.

fabiocav avatar Dec 13 '17 20:12 fabiocav

I think part of the problem is that VS doesn't update the runtime. Microsoft.NET.Sdk.Functions version 1.0.7 only works with 2.0.1-beta.22 cli, and I think vs pulls in a pretty old one. You can grab the beta.22 bits from here https://github.com/Azure/azure-functions-cli/releases/tag/2.0.1-beta.22 and replace the ones in the cli folder if you want to run on the latest v2 runtime.

ahmelsayed avatar Dec 13 '17 20:12 ahmelsayed

I guess it's the cli. You can check this by installing the runtime, but not running the cli at all. When you check the V2 cli folder in %localappdata% you see that its empty. As soon as you hit debug (start he cli) you'll see that folder filling up with the runtime, but it is catching 1.0.6, even if your functions dependency is on 1.0.7. So it behaves the way mentioned by @justcla.

I guess the cli needs to pull the runtime depending on the functions dependencies. This will probably end up with different runtime folders and the cli has to switch based on this, but I guess there is no better solution.

dersia avatar Dec 13 '17 20:12 dersia

@ahmelsayed sounds good, I'll give it a try

dersia avatar Dec 13 '17 20:12 dersia

The first thing to note is that v1.0.6 is the currently supported version of Functions SDK in Visual Studio. And this is why the Functions extension in Visual Studio tries to pull down the 1.0.6 bits.

The next thing to note is that there is a strong dependency between the Functions SDK, the runtime, the CLI and the templates. If you change one, you must change them all to keep them in sync. The CLI will bring down the corresponding runtime, so if you change Functions SDK version from 1.0.6 to 1.0.7, then just go fetch the corresponding CLI for 1.0.7 and at build time, it will fetch the correct runtime. But you will also need to manually update the functions project (generated by the templates) to reference 1.0.7.

justcla avatar Dec 13 '17 23:12 justcla

Currently, when building with Visual Studio, regardless of what Functions SDK version you've specified, it will run against the version of the CLI that it wants. For V1 functions, this comes from a feed, which always has the latest CLI. For V2 functions, it is currently bound to the version that comes with the Functions extension.

Side note: You first get the Functions extension by including it in the Visual Studio installer (i.e. by choosing the Azure workload). This can later be updated by pulling down newer versions from Marketplace.)

Since V2 functions can only run in Visual Studio with the CLI that shipped with the Visual Studio extension for Functions, and that is currently targeting Functions SDK 1.0.6, what that means is that Visual Studio will not be able to build against the CLI or runtimes associated with Functions SDK v1.0.7.

Note: This is not an issue if building from command line. Only an issue if building/running inside Visual Studio.

So, in short, if you want to build and run V2 Functions in Visual Studio, you must stick with Functions SDK v1.0.6 (for now).

justcla avatar Dec 13 '17 23:12 justcla

I was able to force Visual Studio to use a Functions SDK v1.0.7-compatible version of the CLI using the following workaround:

  1. Install the Azure Functions Core Tools 2.0 per instructions here.
  2. In VS, right-click project > Properties > Debug and set the following:
  • Launch: Executable
  • Executable: {full path of .NET Core CLI’s dotnet.exe, ex. C:\Program Files\dotnet\dotnet.exe}
  • Application Arguments: {full path of the Azure Functions CLI assembly you want to run, ex. C:\Users\SomeUser\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\Azure.Functions.Cli.dll} host start
  • Working Directory: {full path of your project’s build output folder, ..\bin\Debug\netstandard2.0}

kashimiz avatar Jan 05 '18 02:01 kashimiz

@kashimiz This workaround is no longer working for me as of v1.0.9. When I try to launch with an exe debug profile I get the generic error:

The program '[14116] dotnet.exe' has exited with code -2147450751 (0x80008081).

Any ideas on what could be causing this?

wartmanrp avatar Mar 20 '18 15:03 wartmanrp

Similar here. I experience another issue which can be related to this.

My methods throws the error below. The strange is that the mentioned Microsoft.Extensions.Configuration.Abstractions is in the directory where other dlls are and the version number matches. I have been investigating it for hours without any clue why. One thing is sure it is related to config json file read, but this code worked a few days ago. If I set the code back to particular commits the issue do not disappear.

[3/20/2018 4:03:54 PM] Host lock lease acquired by instance ID '000000000000000000000000F559816F'.
[3/20/2018 4:03:55 PM] Job host started
[3/20/2018 4:04:41 PM] Function started (Id=738b492d-954f-4133-9f16-49bffd28e99d)
[3/20/2018 4:04:41 PM] Executing 'CountryV1_GetAllAsync_HttpStart' (Reason='This function was programmatically called via the host APIs.', Id=738b492d-954f-4133-9f16-49bffd28e99d)
[3/20/2018 4:04:41 PM] A ScriptHost error has occurred
[3/20/2018 4:04:41 PM] Exception while executing function: CountryV1_GetAllAsync_HttpStart. AzureDurableFunctions: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[3/20/2018 4:04:41 PM] Exception while executing function: CountryV1_GetAllAsync_HttpStart
[3/20/2018 4:04:41 PM] Exception while executing function: CountryV1_GetAllAsync_HttpStart. AzureDurableFunctions: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[3/20/2018 4:04:41 PM] Function completed (Failure, Id=738b492d-954f-4133-9f16-49bffd28e99d, Duration=168ms)
[3/20/2018 4:04:41 PM]
[3/20/2018 4:04:41 PM] Executed 'CountryV1_GetAllAsync_HttpStart' (Failed, Id=738b492d-954f-4133-9f16-49bffd28e99d)
[3/20/2018 4:04:41 PM] System.Private.CoreLib: Exception while executing function: CountryV1_GetAllAsync_HttpStart. AzureDurableFunctions: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
[3/20/2018 4:04:41 PM]   Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '738b492d-954f-4133-9f16-49bffd28e99d'
[3/20/2018 4:04:41 PM] System.Private.CoreLib: Exception while executing function: CountryV1_GetAllAsync_HttpStart. AzureDurableFunctions: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Andras-Csanyi avatar Mar 20 '18 16:03 Andras-Csanyi

@SayusiAndo I get a similar error (except about ms.extensions.mvc.abstractions) even though all of the assemblies are the correct version. I can get the project to build if I use the project launch debug profile, but with the error, if I try executable launch as detailed in the workaround, I get the generic error I mentioned.

It is worth noting, as pointed out earlier in this thread, if I build a new project from the functions CLI everything works just great, but I then just have to use VS Code instead of 2017CE, which is fine by me.

wartmanrp avatar Mar 20 '18 16:03 wartmanrp

Struggling with this today too.

I've managed to get debug and breakpoints working with 1.0.9 in Visual Studio using these settings:

Launch: Executable Executable: %APPDATA%\npm\node_modules\azure-functions-core-tools\bin\func.exe Application Arguments: host start Working Directory: $(TargetDir)

But I can't get my function to work because of conflicting DLL versions between the functions runtime and my referenced .NET Standard libraries (relating to Microsoft.Extensions.Configuration.dll v2.0.1).

cpwood avatar Mar 21 '18 11:03 cpwood

Also struggling with this. I've tried all the variations above for override launch settings.

TimPurdum avatar Mar 21 '18 15:03 TimPurdum

@justcla do you have an update?

patricklee2 avatar Mar 21 '18 17:03 patricklee2