Combining azure functions V2 dotnet from multiple assemblies - azure

I'm implementing Azure functions V2 in dotnet core. Let's say I have two assemblies (of type Azure function) containing Azure functions and I would like to deploy it in a way where azure functions from both assemblies would be loaded in Azure function host.
Functions1.dll (contains functions A,B,C)
Functions2.dll (contains functions D,E,F)
Expected Result:
Function app hosting functions (A,B,C,D,E,F)
I tried to plainly and simply reference these dlls, Function host started,initialized, but no functions were found.

As far as I know, we can deploy the function code in dll to Azure function, please refer to the steps below:
Build the project in visual studio and generate the "bin" and the functions in your project.
Go to the path of your azure function by clicking "Advanced tools (Kudu)" button
In Kudu, click "Debug console" --> "CMD" --> "site" --> "wwwroot", and drag the folders "bin", "Function2", "Function3" from local to the web page.
Restart your azure function app, then you can run the two functions on portal.
If you want to deploy another function project to this function app, we can repeat the steps above. But we need to focus on the differences and the repetition of the two function project in their "bin" folder. The differences and the repetition of the bin folder in these two function projects will cause a lot of problems, so I think deploy to Azure function from dll is not a good solution for us to do the deployment(especially there are two function projects). You can refer to this tutorial to know some more solution to deploy azure function.

Related

Azure function not visible in function list after the function is published to portal

I'm new to Azure function and here found after the function is published to the portal, but it is not visible in the function list. I have attached the snap of sample code and an empty list of azure. plz, help!
////////////////////////////////////////////////////////////
Adding kudu ui, here I found the only host.json in /wwwroot
Hi All
Added kudu ui, here I found the only host.json in /wwwroot
Update:
From your description, it seems the deployment of your azure function is Interrupted or failed. There will be a host.json in wwwroot by default. If you deploy from local, it means it create function app success but didn't upload files to physical path 'wwwroot' (Azure function is based on azure app services sandbox, so if your deployment is success, all of the related files and folder will be upload to wwwroot, this is the physical path, just like the app service. ) I think you can try other ways to upload these files to physical path. For example, ftp deploy or zip deploy. This is the structure of the C# library azure function:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-dotnet-class-library#functions-class-library-project
This is the screenshot of the success deployed function:
(In bin directory, there are many compiled files, including the dll file. In Function1, there is a function.json. These files will be generated after building. For more information, please refer to the above doc.)
You can first build your function app on local and then upload the compiled files to azure.
These are the tutorials of how to use ftp and the zip deploy to upload files: (Just choose one of them is ok. By the way, when you use the VS 2019 to publish function app, it is essentially a zip deployment.)
FTP deploy: https://learn.microsoft.com/en-us/azure/app-service/deploy-ftp
Zip deploy: https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push
Original Answer:
This is an error of portal ui.
It seems that the new version of ui has not been done. But your function should have been deployed to azure.
If you go to kudu, you will find the files has be upload to wwwroot.
You should follow these steps:
And then copy the host key in this place:
(Both of them can be used.) Copy one of them to the end of your request url.
The request url in your function app should be like this:
yourfunctionappname.azurewebsites.net/api/yourtriggername?code=yourkey
And then you can get response.
You can try again at your time, the problem maybe be fixed.(Whether you can see it in ui, you can trigger this trigger, but you need to give a key to pass the verification. The new version of the function ui still has a lot of updates, and even lacks some basic functions. It is trying to unify towards app service, and it should be stable after a while.)

How to add Function App to Resource Group project in Visual Studio 2017?

I'm working on my Azure project for gaining some experience especially in deployment via Powershell. I already created a solution, and added an Azure Resource Group deployment project. Here you can add resources to your group, but there is no Function App, WebJobs or anything similar to Function App, or FaaS stuff.
I checked the automation script created by Azure portal about a manually created Function App, but it is quite heavy. It will take time to figure out how it works.
Is there a way to do it using this tool?
There are two pieces to this puzzle.
1) Is the "Infrastructure as Code" or IaC. In your case the Azure Functions PaaS Service. This can be deployed using an Azure Resource Manager (ARM) template, built using Visual Studio 2017. This is the "runtime/host" that your function will be deployed to. See the Azure Resource Group deployment project type, part of the Azure SDK. Top tip - if you have an Azure Resource Group with a Functions PaaS instance in it, go to the instance and click on Platform Features -> Automation Template. This will give you the foundation for building your resource group deployment project.
2) Is the function itself. This needs to be deployed to your Azure Functions PaaS service. Azure functions have their own project type in Visual Studio 2017, however the template needs to be download. See Visual Studio 2017 Tools for Azure Functions.
Once you have built your function using (2) above, you publish to your function PaaS instance deployed (which was either manually deployed or deployed using (1) above).
Top Tip 2: You can build and test functions locally using the Azure Functions CLI.
Top Tip 3: Use the Azure Resource Explorer to help understand how the ARM structure looks for your subscriptions.

Can Azure Functions be deployed to IIS?

I've been trying out Azure Functions and have deployed them successfully to Azure. As their name suggests, Azure Functions are intended to be deployed to Azure. However, now I have the need to deploy those functions to local IIS.
I'm aware that I can adapt the code and create a regular WebAPI project instead, but was wondering if the Azure Function project can be deployed to IIS as-is or with minimal changes.
In Visual Studio there doesn't seem to be an option to publish to local IIS. I tried the option to publish to a Folder (bin/Release). I tried to deploy those files to IIS but it doesn't seem to work.
If you need to run Functions on your own infrastructure, you should use Azure Functions Runtime.
It is deployed to Windows Containers (not IIS), but it will give you a similar experience to Azure-hosted Function Apps.

Azure Functions not showing in Function App

How does Function App detects if a folder contains Functions?
As an incentive for the upcoming Azure Function Tools for VS, I followed the article here: https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/
I have successfully created Azure Function as a web-app project in Visual Studio, deployed the Function App using ARM template, then deployed the Functions using release step in Visual Studio Team Services.
Here are the contents of my Web App project, 'CustomerERPChange' is the Function that I want to get it showing in Azure.
Web App Project
What I'm expecting to see is the Function appearing in the Function App, but that doesn't seem to be the case..
Looking at Kudu I can confirm that the content of my project has been successfully deployed to the ../wwwroot directory, renaming the 'run.cs' back to 'run.csx' also didn't help.
Any idea and suggestion would be appreciated, thanks!
There are two ways to create function within Functions App,
1) using UI Create function with template of your choice,
2) from KuDu portal,
go to your_app_name.scm.azurewebsites.net,
create a folder in home > site > wwwroot > (function_name),
add run.csx or run.ps1, and function.json file to the newly created folder.
About these files :
run.csx or run.ps1 is a file which will automatically gets called when the function is executed.
function.json is a file which defines your function(either it is a timer or HttpTrigger, or other).

How do I use external assemblies with Microsoft Azure Function Apps?

The documentation says that you can put a DLL in a bin folder and reference it using a special #r syntax, however in the Azure portal I cannot find how to upload these DLLs. Is this possible, and if so, how is that supposed to be accomplished?
This is possible.
You can use Kudu to upload your binaries:
Open the app's Kudu portal. If your Functions App's URL is samplefunctions.azurewebsites.net, then go to samplefunctions.scm.azurewebsites.net.
Click on the Debug console menu and select PowerShell. This will open up a PowerShell console plus a file explorer. Navigate to D:\home\site\wwwroot.
There you should see a folder which is named after your existing function. Navigate to that folder and drag-n-drop your binaries inside bin folder.
Now you can use them with #r directive.
I think you should also be able to configure the continuous deployment of your libraries to Functions (e.g. from a Git repo). Go to Function app settings -> Configure Continuous Integration.
Azure functions now has runtime support for precompiled functions.
https://blogs.msdn.microsoft.com/appserviceteam/2017/03/16/publishing-a-net-class-library-as-a-function-app/
You’ll need to use a web project which will provide the full development experience of IntelliSense, local debugging, and publishing to Azure. The instructions above detail how.
You're able to deploy your functions that has some external references just doing the deploy by Visual Studio Functions Tools.
Just configure your Azure account in your visual studio deployment settings, for your azure functions and play deploy. All references will be there in your Function App on azure.
You can use Octopus Deploy (Website deployment step) to deploy a function.
The folder structure of the nuget package pushed to octopus deploy should be:
nuget_package.nupkg
|--bin
|--*.dll
|--run.csx
|--function.json
You can add assembly reference with a relative path.
In portal.azure.com -> function apps, on the right hand side, View Files -> upload the dll (eg: YourDllName.dll).
In run.csx, enter #r "./YourDllName.dll"

Resources