0
votes

We are looking to implement reusable functionality within more than one of our products.

What I would like to do is:

  • Create a C# project that contains one or more Azure Functions (static methods with the FunctionNameAttribute attached to them)
  • Turn this project into a NuGet package
  • Reference this NuGet package in an Azure Functions project
  • Have the function(s) from the NuGet package exposed in the project it is being used in

Whilst I find that it all compiles, the functions in the NuGet package are not "found" on startup and are ignored. I can see that this could be desirable for security reasons, but I'm wondering if there is a way to overwrite how the functions runtime operates to say "scan this assembly and use any functions contained within it".

Even having that custom code would be preferable to the situation in which we find ourselves - having joint functionality in our package that is referenced by two different products, but each of the products having to create a duplicate set of functions that then call the common code.

1
Why do you want to convert the AZF to a nuget package? I think that you should just consume the AZF from the other project through a normal request call. - Felipe Santiago
It's kind of hard to explain the use case - but basically, whilst the code in the AZFs will be the same regardless of the product they are servicing, the code underneath them will be different depending on the product. So ProductA needs to call ProductA-AZF that will have the standard function signatures but do ProductA specific things "under the hood". And then ProductB will have a different deployed function app ProductB-AZF that it needs to call. - DenverCoder9

1 Answers

1
votes

I think that the best approach for this would be through git submodules and not Nuget packages.

Create a project that both products will reference. A base class that will have some methods that you can overwrite or just reuse in both solutions by inhering it from the base class.


Following your comment, let's try this workflow:

1 - Write a AZF project with Swagger, for all the Product common operations.

2 - Write a new Project to have the ProductBase class that will consume all the Product REST endpoints.

3 - Convert the Consume project to a Nuget Packages.

4 - Install it in both Projects A and B, and Inherit the Base product class