Azure-functions-core-tools: --useHttps seems to crash the CLI 2.0 Preview

Created on 30 Aug 2017  路  12Comments  路  Source: Azure/azure-functions-core-tools

I just tried the CLI 2.0 Preview on a function app that uses EFCore 2.0.

The CLI shows the ASCII art, sit there for about 30 seconds and then shows the following error:
image

If I remove --useHttps, it works fine.
If I use --useHttps using the 1.0.2 CLI, it also works fine.

Most helpful comment

Probably because it hasn't been implemented yet :) But this is a good place to track adding it.

All 12 comments

Probably because it hasn't been implemented yet :) But this is a good place to track adding it.

Fair enough :) Do you have a rough idea on when it might be available - even if just in preview - so I can try again then?

I just pushed a change to support --useHttps
The behavior is a bit different from V1.

In V1 I was using Window APIs for auto generating a random cert. I need to have a better flow for cross plat, but for now you need to pass --cert <cert.pfx> --password <password or file with password>

it should print instructions if you don't though. I'm hoping to eventually automate it (maybe) but for now this should unblock you.

image

image

and this is it working
image

I just pushed it to npm, so you can run npm i -g [email protected] to get it.

Thanks @ahmelsayed!

I created the PFX using PowerShell. Since I was already in a command prompt, I just tried to launch the function app directly from there. The function app launched with the following:
%USERPROFILE%\AppData\Roaming\npm\func.cmd host start -port 7071 --useHttps --cors * --cert .\certificate.pfx --password "<password>"

However, when I trigger a function I get an exception I'd like to debug in VS.

I was able to debug in VS with the CLI 2.0 Preview before upgrading to 2.0.1-beta.11 by modifying the project config like this:
image
This "worked" in that the CLI launched, the ASCII art displayed... but eventually it crashed due to the --useHttps flag.

After the upgrade to the CLI and after seeing the CLI start the function app from the command prompt, I assumed that I'd be able to debug it in VS similarly, by appending --cert .\certificate.pfx --password "<password>" to the application arguments:
image

However, now I immediately get an error that says "The sytnax of the command is incorrect." The ASCII art doesn't even display.

Should I be debugging the function app differently with CLI 2.0?

I suspect the error I'm getting is related to .NET Standard 2.0 support, but I'm not sure. Here's the exception in case it is helpful to you.

[9/1/2017 12:52:16 AM] A ScriptHost error has occurred
[9/1/2017 12:52:16 AM] Exception while executing function: Applications. Service: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
[9/1/2017 12:52:16 AM] Exception while executing function: Applications
[9/1/2017 12:52:16 AM] Exception while executing function: Applications. Service: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
[9/1/2017 12:52:16 AM] Function completed (Failure, Id=20c37b66-9975-42a3-97aa-2a031d86a46f, Duration=49ms)
[9/1/2017 12:52:16 AM]
[9/1/2017 12:52:16 AM] Executed 'Applications' (Failed, Id=20c37b66-9975-42a3-97aa-2a031d86a46f)
[9/1/2017 12:52:16 AM] System.Private.CoreLib: Exception while executing function: Applications. Service: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
[9/1/2017 12:52:16 AM]   Function had errors. See Azure WebJobs SDK dashboard for details. Instance ID is '20c37b66-9975-42a3-97aa-2a031d86a46f'
[9/1/2017 12:52:16 AM] System.Private.CoreLib: Exception while executing function: Applications. Service: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Thanks again for your help! Also, if it'd be easier to sort this out over a Skype session, I'd be happy to. My alias is padal.

/cc @fabiocav for the exception loading System.Net.Http.Formatting

regarding VS, the V1 cli was an executable, while the v2 cli is a dll, so far.

these 2 configurations work for me

Executable: C:\Program Files\dotnet\dotnet.exe
Application arguments: %USERPROFILE%\.azurefunctions\bin\Azure.Functions.Cli.dll host start --port 7071 --useHttps --cors * --cert "D:\temp\cert.pfx" --password "D:\temp\password.txt" --pause-on-error
Working directory: <>

I think the problem with specifying a cmd for VS is that they probably expect an executable rather than a shell script.

however, for whatever reason F5 debugging isn't working for me, I get this weird error from VS

image

But if I do CTRL+F5 then go Debug -> Attach to Process -> search for dotnet.exe, debugging works fine for me.

Thanks @ahmelsayed!

I can launch with CTRL-F5, and attach the debugger now.

However, after triggering the function I still see the exception I mentioned earlier in the CLI window.
Also, my breakpoints in VS don't hit - even one in the constructor of the function.

@fabiocav Can you take a look at the assembly loading exception? I won't expect any of the function's code to be ran until all the dependencies have been loaded.
@pauldalyii What packages are you referencing in your csproj?

@pauldalyii yeah, if you can provide a quick repro, we'll take a look at that.

Happy to provide a repro. How would you like me to share it? I'm an FTE (padal), so I can also do a Skype session if that's easier.

The function project directly references these packages:
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.4.0" /> <PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.16.0" /> <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.2" /> <PackageReference Include="Microsoft.Web.WebJobs.Publish" Version="1.1.0" /> <PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.0" /> <PackageReference Include="System.ValueTuple" Version="4.4.0" />

But the function project also indirectly references other packages via 3 project references:

From Project 1:
<package id="Microsoft.Net.Compilers" version="2.3.1" targetFramework="net47" developmentDependency="true" />,

Project 2:
<package id="Microsoft.CSharp" version="4.4.0" targetFramework="net47" /> <package id="Microsoft.EntityFrameworkCore" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.EntityFrameworkCore.Design" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.EntityFrameworkCore.Relational" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.EntityFrameworkCore.SqlServer" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.EntityFrameworkCore.Tools" version="2.0.0" targetFramework="net47" developmentDependency="true" /> <package id="Microsoft.Extensions.Caching.Abstractions" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Caching.Memory" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Configuration.Abstractions" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.DependencyInjection" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Logging" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Logging.Abstractions" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Options" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Primitives" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Net.Compilers" version="2.3.1" targetFramework="net47" developmentDependency="true" /> <package id="Remotion.Linq" version="2.1.2" targetFramework="net47" /> <package id="System.Collections" version="4.3.0" targetFramework="net47" /> <package id="System.Collections.Immutable" version="1.4.0" targetFramework="net47" /> <package id="System.ComponentModel.Annotations" version="4.4.0" targetFramework="net47" /> <package id="System.Data.SqlClient" version="4.4.0" targetFramework="net47" /> <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net47" /> <package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net47" /> <package id="System.Interactive.Async" version="3.1.1" targetFramework="net47" /> <package id="System.Linq" version="4.3.0" targetFramework="net47" /> <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net47" /> <package id="System.Linq.Queryable" version="4.3.0" targetFramework="net47" /> <package id="System.ObjectModel" version="4.3.0" targetFramework="net47" /> <package id="System.Reflection" version="4.3.0" targetFramework="net47" /> <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net47" /> <package id="System.Runtime" version="4.3.0" targetFramework="net47" /> <package id="System.Runtime.CompilerServices.Unsafe" version="4.4.0" targetFramework="net47" /> <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net47" /> <package id="System.Threading" version="4.3.0" targetFramework="net47" />

and Project 3:
<package id="Microsoft.EntityFrameworkCore" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Caching.Abstractions" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Caching.Memory" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.DependencyInjection" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Logging" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Logging.Abstractions" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Options" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Extensions.Primitives" version="2.0.0" targetFramework="net47" /> <package id="Microsoft.Net.Compilers" version="2.3.1" targetFramework="net47" developmentDependency="true" /> <package id="Remotion.Linq" version="2.1.2" targetFramework="net47" /> <package id="System.Collections" version="4.3.0" targetFramework="net47" /> <package id="System.Collections.Immutable" version="1.4.0" targetFramework="net47" /> <package id="System.ComponentModel.Annotations" version="4.4.0" targetFramework="net47" /> <package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net47" /> <package id="System.Diagnostics.DiagnosticSource" version="4.4.1" targetFramework="net47" /> <package id="System.Interactive.Async" version="3.1.1" targetFramework="net47" /> <package id="System.Linq" version="4.3.0" targetFramework="net47" /> <package id="System.Linq.Expressions" version="4.3.0" targetFramework="net47" /> <package id="System.Linq.Queryable" version="4.3.0" targetFramework="net47" /> <package id="System.ObjectModel" version="4.3.0" targetFramework="net47" /> <package id="System.Reflection" version="4.3.0" targetFramework="net47" /> <package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net47" /> <package id="System.Runtime" version="4.3.0" targetFramework="net47" /> <package id="System.Runtime.CompilerServices.Unsafe" version="4.4.0" targetFramework="net47" /> <package id="System.Runtime.Extensions" version="4.3.0" targetFramework="net47" /> <package id="System.Threading" version="4.3.0" targetFramework="net47" />

Basically, I have a function app project and a handful of data access projects that the function app project references.

hi @ahmelsayed, since https seems to be working now, would you like me to open a separate issue regarding the exception I'm seeing while trying to debug a function app referencing ef core 2.0?

@pauldalyii Yes please, that will make it easier to track

Was this page helpful?
0 / 5 - 0 ratings