vblang icon indicating copy to clipboard operation
vblang copied to clipboard

VB.NET in Azure Functions

Open InteXX opened this issue 6 years ago • 46 comments

FYI I was able to get a pure-VB.NET Azure Function working. It was pretty simple, really—here's what I did:

  1. Created a C# sample using this guidance

  2. Created a new VB.NET project (in .NET Standard 2.0 instead of .NET Core 2.2—I ran into missing dependency problems while trying it in Core)

  3. Converted the C# sample class using Telerik's Code Converter

  4. Added the converted code to the VB.NET project (being careful to remove the redundant namespace declaration)

  5. Per this advice, added the AzureFunctionsVersion element to the VB.NET project's XML:

     <PropertyGroup>
       <RootNamespace>FunctionApp1</RootNamespace>
       <TargetFramework>netstandard2.0</TargetFramework>
       <AzureFunctionsVersion>v2</AzureFunctionsVersion>
     </PropertyGroup>
    
  6. Published and tested as normal

If you're using WebDeploy (uncheck the 'Run from package file' checkbox at first publish), you'll see a warning during deployment:

Could not evaluate 'Microsoft.CSharp.dll' for extension metadata. Exception message: Could not load file or assembly 'Microsoft.CSharp, Version=4.0.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

This warning can be safely ignored. Best guess, the assembly is probably only necessary as an interpreter for C# Script functions.

Due to my limited bandwidth I can only publish via WebDeploy, so I'm not aware of whether the warning occurs during a ZipDeploy (checking the Package checkbox).

And there we have it—an Azure Function in pure VB.NET.

InteXX avatar Sep 04 '19 11:09 InteXX

Does the local debugger and such work?

aarondglover avatar Nov 29 '19 13:11 aarondglover

Yes.

InteXX avatar Nov 29 '19 15:11 InteXX

No that I expect it to change but have your tested with azure function be (and .net core 3.1?)

aarondglover avatar Dec 13 '19 08:12 aarondglover

I haven't.

InteXX avatar Dec 13 '19 11:12 InteXX

No that I expect it to change but have your tested with azure function be (and .net core 3.1?)

Perhaps I did not clearly understand what @aarondglover asks, but I'm converted full C# based azure function into full VB.NET with .NET Core 3.1 and test it, deploy it in App Service also.

rrvenki avatar Feb 07 '20 08:02 rrvenki

I meant to say "Azure Function 3.0 (and .NET Core 3.1)"

aarondglover avatar Feb 26 '20 05:02 aarondglover

@InteXX or @rrvenki

Can either of you please publish an empty/sample project to GitHub which I can clone to get started?

aarondglover avatar Mar 14 '20 11:03 aarondglover

@aarondglover

Did you run into problems with the steps above? They may be in need of revision if so.

InteXX avatar Mar 14 '20 17:03 InteXX

@aarondglover

How did you fare with this? Were you able to get it working?

InteXX avatar Apr 12 '20 12:04 InteXX

@aarondglover if you require a simple sample Azure functions project in VB I can share it.

rrvenki avatar Apr 29 '20 12:04 rrvenki

@rrvenki

Thank you, yes please.

InteXX avatar Apr 29 '20 15:04 InteXX

ahh.. Finally... I've ended up using a different approach. Here's my result:


2020-05-08T18:45:40.538 [Info] Function started (Id=XXXXXXXX-XXXX-XXXX-XXXX-cbc5XXXXX7)
2020-05-08T18:45:40.538 [Info] VB 64bit (Framework 4.8) HTTP trigger function processed a request.
2020-05-08T18:45:40.538 [Info] Function completed (Success, Id=XXXXXXXX-XXXX-XXXX-XXXX-cbc5XXXXX7, Duration=10ms)

SilverfoxSystems avatar May 08 '20 19:05 SilverfoxSystems

@SilverfoxSystems

Could you provide some more detail?

InteXX avatar May 08 '20 19:05 InteXX

I've created a new function in VS2019 and there I've examined the "MS.NET.Sdk.Functions" package. Using VS2015, I created a Class Library and manually imported each package from the mentioned package. Converted the VS2019 C# code into VB and so on... Further details (and maybe a step-by-step procedure) will be available on my website.

SilverfoxSystems avatar May 08 '20 20:05 SilverfoxSystems

I found this:

http://silverfox.systems/

Will you be publishing something there?

InteXX avatar May 08 '20 20:05 InteXX

Yes, that's it. I will notify you here when it will be ready.

SilverfoxSystems avatar May 08 '20 20:05 SilverfoxSystems

@SilverfoxSystems

Sounds good, thanks. I'm looking forward to it.

InteXX avatar May 08 '20 20:05 InteXX

There we go:

http://silverfox.systems/Azure_VB_Function.aspx

The page still needs a bit of styling, but it'll do for now... You're welcome.

SilverfoxSystems avatar May 08 '20 23:05 SilverfoxSystems

@SilverfoxSystems

Looks good, I like it!

I think I'm going to work up a template based on this. With your permission, of course.

InteXX avatar May 09 '20 03:05 InteXX

@InteXX Sure, go ahead... I'm considering automating the whole process myself.

SilverfoxSystems avatar May 09 '20 06:05 SilverfoxSystems

Oh man, thanks for the donation there! Fair play to you, it's really gonna help me out in my current situation.

SilverfoxSystems avatar May 09 '20 07:05 SilverfoxSystems

I think I'm going to work up a template based on this.

Why should C# coders have it any more comfortable anyway :)

SilverfoxSystems avatar May 11 '20 21:05 SilverfoxSystems

I've added a repo, if someone's interested...

SilverfoxSystems avatar May 14 '20 09:05 SilverfoxSystems

Watched and starred. I'll fork it in the next few days. Thanks

Padanian avatar May 14 '20 09:05 Padanian

Watched and starred. I'll fork it in the next few days. Thanks

Good man! You're welcome.

SilverfoxSystems avatar May 14 '20 11:05 SilverfoxSystems

for as much as I would be interested, I'm not even considering an ecosystem that carries along 49 (fortynine) dlls for a hello world proof of concept. A 12kb executable carries along 23MB of libraries and descriptors. Thanks, but no thanks.

Padanian avatar May 14 '20 19:05 Padanian

@Padanian

That's Azure Functions for you ;-)

InteXX avatar May 14 '20 21:05 InteXX

@Padanian That is only if you don't use Pack, with Core 5.0 the total app of Hello World size is 155KB on Windows.

paul1956 avatar May 14 '20 23:05 paul1956

@paul1956

Are you referring to this?

InteXX avatar May 14 '20 23:05 InteXX

@InteXX never mind it is smaller but not that small. The feature is PublishTrimmed

paul1956 avatar May 15 '20 00:05 paul1956