I want to use some shared classes on my Azure Functions to not duplicate code.
I have tried to create a empty C# function and create the classes inside the function
Let me answer this question in a more human-understandable way taking into account that Azure Functions are new and don't have proper documentation yet.
Let's go step by step.
You need to go to the Azure function "Platform features" section.
Then Navigate to Development tools->Advanced tools:
Next, navigate to Tools->Zip Push Deploy:
Next, create a folder called "Shared" inside root folder as it recommends in Microsoft documentation:
Inside this folder, you can also create additional folders, classes if you want, for example, if you want to reuse Model classes between Azure functions then create an additional folder called "Models" and put your desired class there.
After the creation of *.csx
file you can edit it and put your code there and save:
Then reuse the class inside you Azure function by loading it using #load
:
Note:
Yet another way is to use Visual Studio with Microsoft DevOps CI/CD. There it will be much straightforward and easy to do the same.