Azure Functions publishing - azure

Firstly I would like to describe my local project structure. I have three Azure Functions v2. Locally each function have separate project. The fourth project is library which functions are using.
I would like to publish those functions into one function on Azure ( one App Service). And there's the issue occurs.
Let's start with an example. Let's say the function names are : A, B, C.
Firstly I publish functions in order: A, B, C. Then I've change something in function B, and publish only B. Then the function A, and C are not working.
I've must publish all functions to work again.
My first thought was package incompatibility and resolved that. But the issue still occurs. The web publish file does not contains any info about any additional packages/dlls.
Do you have any tips?

Your intention itself that publishing several Function projects to one Function app is incorrect.
See the official guidance.
In most scenarios, the unit of deployment should be the Function App, and not individual functions. Deploying a Function App is essentially identical to deploying a Web App.
Locally one Function project represents exactly one complete Function app, so one Function app should host only one published Function project. Otherwise we may see inconsistent behavior after publishing which results from content overwritten and so on.
My suggestion is to put functions together in one project, merging usually doesn't bring trouble unless there are specific host settings for each project.

Related

Deploying Azure Functions to a specific function within multiple without overwriting the others

I have 2 Function Apps in Production with several functions each.
When I want to deploy the VSCODE project of specific Function (project) the prompt asks me to choose the Function App to deploy to, and after I'm choosing the right one - it actually deploys the same set of functions to the other Function App as well.
These are the functions inside - it's always identical even deploying from different project:
I'm trying to figure what am I missing here.
Any help is appreciated. Thx
Solution is found.
It happened to be that the configuration of WEBSITE_CONTENTSHARE had the same value for both Function Apps.
Changing that to a unique value per App fixed the issue and now we can deploy each bundle to the relevant App.

Deploying an Azure Function from VS Code - Succesfull but not visible in the Portal

I created a function and I am trying to deploy it from VS Code by clicking the Deploy to Function App.... The Deployment runs successfully based on the output log - Deployment successful but then when I go to the portal, the function is not listed under Functions.
What shall I do and what is the problem here?
When I debug in VS Code, I get this: No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
Unfortunatly I would not know if those steps don't work for uploading. The deployment finishes, and every single time it becomes visible in my portal. Uh, maybe there is a slight difference. The app service itself is pre-created via terraform. Just the uploading of the code I do via VSC.
As far as deletion goes:
Open the resource group, in the list lookup the App Service. Select the checkbox in front of it. Delete in the top nav bar of that pane.
Trying to delete it any other way will indeed give you the "Not found" error.
I've had the same 'issue', in my case it turns out that the issue was a bad entry in the requirements.txt
I had an incorrect line with 'io' and when it was present despite the deployment appearing to complete successfully in VS code, the function was not updated if it was previously deployed or not deployed if it wasn't resulting in the same 'no results' in the functions list.
Having other requirements such as 'numpy' or 'scipy' worked just fine.
It's an old thread but maybe it'll be helpful to whoever gets here in the future.
Even as of now, some changes I make in VS Code seem to take time to be immediately visible on the portal. I had a similar issue with resources, i.e. creating a resource from VS Code wouldn't make it immediately visible on Azure Portal. You can always go to Functions on the portal and click Refresh. Also try going to Advanced Tools, then Kudu and checking if your function can be found there.
One word of advice: if you publish your functions from VS Code, then work on that resource only from VS Code. You will find it reiterated all over Azure Functions docs that:
Publishing to an existing function app overwrites the content of that
app in Azure.

All Function Apps turn to Read only mode after publishing Azure function project via Visual Studio 2017

I have a Function Apps created via Portal, another one created by visual studio. The latter one cause both apps to become read only, with message below:
Your app is currently in read-only mode because you have published a
generated function.json. Changes made to function.json will not be
honored by the Functions runtime
Is this feature correct?
VS: 15.8.5
Yes, this is by design. Function Apps you mentioned should be called functions in one same Function app.
You create a Function app and a function on portal, then in VS you actually also create a Function app instead of a separate function. After you publish this pre-compiled Function app to the one with some existing functions, Azure thinks you want to use the new published one, so it sets the app to be read-only as we can't modify pre-compiled assets on portal unless we republish our code.
This action is by design because one Function app(with functions inside) is handled as a complete unit. So apparently it's not recommended to mix online development with pre-complied one.
Two choices for you to refer.
Remove existing functions in the app. Check Remove additional files at destination when publishing from VS.
Create another Function app.
There are risks that mixing online and pre-compiled code from VS, for example
Name restriction. Functions created online will be overwritten if we publish functions with same names.
We can't check Remove additional files at destination even though some pre-complied dlls published before have been useless.
If it's only for test or there's no worry about potential risks, just change Function app edit mode to readwrite in Function app settings or add FUNCTION_APP_EDIT_MODE readwrite in Application settings.

Debugging two Azure Functions projects locally

I have two Azure Functions projects.
I have one project, A, running on localhost:7071/api/....
I have changed the other project, B, to run on localhost:8888/api/...
I am calling a function which is running on project A from a function in Project B! How can I debug two Azure Functions projects locally? I cannot find any docs to help me.
To fix the issue add the command line switch --nodeDebugPort 5859 to your launching of func host to set the port for one of the sessions.
If you are launching from within Visual Studio you need to go to Project -> Properties -> Debug, then under Application arguments you need to pass in a value that looks similar to host start --pause-on-error --nodeDebugPort 5859 (again, for one project).
See this issue and this video.

Azure WebJob-Project - access parent project artifacts

I am new to Azure WebJobs. For a mobile app we need some WebJobs that can run scheduled. My question is about the "Projects-Architecture" when it comes to WebJobs.
As far as i know, a new project is created for every WebJob. I am doing this by righclicking the main project -> add new azure webjob project.
But how are these projects "combined". There should be some reference to the parent project that i cannot find. I need to access the entities from the main project inside the WebJob. How should this be done?
Furthermore i am not sure wheter to implement Logic+Data access directly inside the WebJob or let the WebJob instead call another Controller to handle this?
Documentation on this is horrible, every help would be great.
They are not really "combined". There is a reference in the Web App (the webjobs-list.json) in properties that tells VS to publish the webjob when you publish the web app. If you need to access entity models in the webjob, then you need to add a reference to your other projects just like you would in any other project (add the project reference and then add a using statement in the webjob). The reference will get compiled into the webjob.
May I ask what are you trying to achieve via the web job? this would help in identifying why the need for accessing the models of your MVC app.
One suggestion would be to push the object from the MVC app to an azure queue and then access it via your job. Set it up in a way to identify new messages in a queue. (trigger). - not sure if this helps cause I am not sure how quick the web job is run and what are the other constraints you are working with.
When you add a new or existing WebJob Project to your solution, Visual Studio will take care of this for you. It is not something new, as if you are adding a console/windows service project to your web/MVC application.
If you need these projects to communicate, you till need to add references to your other projects just like you would in any other project which will in turn get compiled.
If you need to learn more and check some examples, this tutorial https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-get-started/ shows how to write code for a simple multi-tier ASP.NET MVC 5 application that uses the WebJobs SDK. Maybe that can give you some information on how to architect the application.

Resources