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).
Related
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.)
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.
I am trying to publish an Azure function project from Visual Studio to a brand new Function App in Azure.
Unfortunatly, the publish script only publish one of the two functions to Azure. I do not see any folders about the missing function. I am trying to figure out how to publish both functions in a single Azure function App.
Do I need to change the host.json file? Do I have to change any settings in the project?
I am using the publish to Azure functionnality in Visual Studio. I created a profile connected to my azure account.
Thanks alot,
It looks like the floowing instruction was missing in my csproj file:
<None Update="FunctionName/file">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Doing so creates the correct directory in the fonction App allowing the App to detect the missing functions and displaying them to the portal.
I have 2 questions:
I need some json data from a json file which I am copying while
building the project. Then I published the code from visual studio
2015 but when the code runs on Azure, it can't access the file in
the folder from where dll is being executed. How can I get data from
that file.
When I pushed the Azure function from visual studio to Azure,
appsettings.json values are not being published to Azure.
Please refrain from asking 2 questions in one.
The answers:
You can get the path to current directory from Execution Context, see Retrieving information about the currently running function.
App.setting file is not used in actual deployment of FunctionApp, you should define your settings in environment variables, see How to manage a function app in the Azure portal.
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"