1

my Azure function is v2. I have added <PackageReference Include="SSH.NET" Version="2016.1.0" /> into ItemGroup in function.proj.

However, #r "Renci.SshNet" is NOT working. #r "D:\home\site\wwwroot\bin\Renci.SshNet.dll" is NOT working either. Because there is no bin folder under wwwroot.

What is the normal way to include Renci.SshNet?

Regards, Zhenyu

my function.proj screenshot

  • With Hury's instruction, manually upload .dll makes compile ok. However, should it be automatically downloaded from Nuget, without manually upload? Also, in SSH.NET.2016.1.0 package, there is only netstandard1.3 as highest version. That version does not work in Azure Function v2.0 It throw 'Could not load the specified file.' – Zhenyu Wang Sep 17 '19 at 04:03
  • See [How can I use NuGet packages in my Azure Functions?](https://stackoverflow.com/q/36411536/850848) – Martin Prikryl Sep 17 '19 at 05:52
  • I just found, SSH.NET is not working with .Net Core 2 in Azure Function. – Zhenyu Wang Sep 17 '19 at 06:16

1 Answers1

1

You can add bin folder under wwwroot and drag the dll to it by "Advanced tools(kudu)" under azure function "Platform features" tag.

First, click "kudu" (shown as below screenshot)

enter image description here

Then click "Debug console" --> "CMD" --> "site" --> "wwwroot" --> "New folder" and namd the folder as "bin".

enter image description here

Then drag the dll file to the bin folder and then you can use it by #r command(shown as below)

enter image description here

Update:

You can try to modify your function.proj as below:

<PackageReference Include="Renci.SshNet.Async" Version="1.4.0" />

And in your function use the command "using Renci.SshNet;".

And remove the #r line of Renci.SshNet you added before.

Please have a try.

Hury Shen
  • 14,948
  • 1
  • 9
  • 18
  • Hi Hury, Thank you for quick reply. Yes, the .dll is available with manually upload. However, should it be automatically downloaded from Nuget, without manually upload? Also, in SSH.NET.2016.1.0 package, there is only netstandard1.3 as highest version. That version does not work in Azure Function v2.0 It throw 'Could not load the specified file.' – Zhenyu Wang Sep 17 '19 at 03:59
  • Hi @ZhenyuWang, this post may help you: https://stackoverflow.com/questions/36411536/how-can-i-use-nuget-packages-in-my-azure-functions – Hury Shen Sep 17 '19 at 04:31
  • Hi Hury, I read that post before asking this question. I just found, SSH.NET is not working with .Net Core 2 in Azure Function. But it is working in local console app – Zhenyu Wang Sep 17 '19 at 06:16
  • Hi @ZhenyuWang, could you please share the screenshot of your "function.proj" – Hury Shen Sep 17 '19 at 06:58
  • Hi Hury, screenshot added in original post. (I only can add link) The Nuget package did not installed. Until I manually upload from kudu using the way you suggest, then I can using 'Renci.SshNet' – Zhenyu Wang Sep 17 '19 at 07:08
  • Hi @ZhenyuWang, I have updated the answer, please have a try. – Hury Shen Sep 17 '19 at 08:26
  • Hi @ZhenyuWang, may I know if your issue was solved ? – Hury Shen Sep 18 '19 at 00:55
  • Hi @Hury Shen I found some strange things. In my existing function, whatever I add into ItemGroup, there is nothing shown in the log, especially the blue 'Restoring package for ...' Then I just tried to create a new function, everytime I change the ItemGroup, there are several 'Restoring package for ...' And the SSH.NET 2016.1.0 is working in the new function. – Zhenyu Wang Sep 18 '19 at 00:57
  • It looks my 1st function does not load any NuGet package. – Zhenyu Wang Sep 18 '19 at 01:00
  • @ZhenyuWang So have your second function loaded the NuGet successfully ? – Hury Shen Sep 18 '19 at 01:01
  • yes, the 2nd function load the NuGet successfully, and then I can using 'Renci.SshNet' directly. Is there any setting, allow/prevent the function to load NuGet in an Azure Function? – Zhenyu Wang Sep 18 '19 at 01:03
  • @ZhenyuWang Sorry I'm not so clear about your this question. If you want to load the NuGet, just add it to function.proj and if you don't want to load it, just remove it. If your problem is solved, could you please mark my answer. Thanks~ – Hury Shen Sep 18 '19 at 01:10
  • Hi @Hury Shen, Yes, my problem is solved, by using the new created Function. I will make your answer. Thank you very much for help. – Zhenyu Wang Sep 18 '19 at 02:10
  • @ZhenyuWang I'm sorry, not make my answer. Should be accept my answer(mark my answer), as this link shows: https://stackoverflow.com/help/someone-answers Thanks. – Hury Shen Sep 18 '19 at 02:12