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

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.

Related

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.

What is the best way to move an online Azure Function to a local git repository?

I have written an Azure Function App by using the User Interface of Azure Portal. The code is written in C#.
Now, I want to:
download all of the relevant code and configuration files of this
function app
Create an IDE project (e.g. IntelliJ, Visual Studio Code, ...)
store it in a git repository
Deploy the code from IDE or command line to Azure and thereby replacing the previously written Azure function.
So far, I have found only documentation on how to initiate Azure function projects with no previous code. Does somebody know how to do above?
Yes, you could go to your function Overview page, click on Download app content as shown below.
And in your situation, you want configuration files, so select the Content and Visual Studio Project and Include app settings in the download. What is app settings? This will include a local.settings.json file which contains your application settings.
Also the third party .dlls are included.
In the VS, select the folder and it will be working.
Update:
Open the function with vs, then just right click the function and choose Publish, it will show you the publish page. Click start, then you will be able to publish it to a existing Function.
Follow this Setting up a CI/CD pipeline for Azure Functions doc which explain each step in detail.

How to debug Azure Functions using Visual Code

I have an existing set of functions in an Azure Functions App written in C# Script. I've downloaded the zip file from the Azure portal and opened the directory in Visual Code. I can also log on to the Azure account from Visual Code and can see the functions. If I right-click, I get options to start and stop streaming logs
However, I don't know how to configure my environment so that I can edit and debug these functions locally. I've found instructions for creating a new Function App, but haven't found ones that describe how to work with an existing app.
As mentioned in this post, for now we can't debug(add break points to) C# script(.csx) functions in VS Code.
We can only run csx function both on Azure and locally. Open the function app folder in VS code, follow steps below.
Check function runtime version(~1 or ~2) and follow tutorial to install Azure Function core tools.
If we use ~2 runtime, you need to register binding extensions for all triggers/in/output except Http and Timer triggers.
If we want to use settings(like AzureWebJobsStorage) in Application settings, copy them into local.settings.json. Or we can right click on Application settings of the Function app in VS Code, click Download Remote Settings(In this way, some invalid settings for local env are downloaded as well).
Input Ctrl+` to open terminal and input func host start in terminal to run functions.
For local dev, I do recommend you to use C# pre-compiled code instead of C# script, which is much easier to work with. To do this transformation, follow this tutorial, new a c# function app locally, copy your code in .cs files. We basically don't need to modify the logic code except adding some package and namespace references.

Azure Functions publishing

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.

Where can i find the code of an Azure Function?

I'm new to Azure Functions and been thrown into a project without a proper introduction and anybody I could ask is out of office. My simple most likely stupid question is; where can I find the actual code?
In the azure portal, the functions are listed as "read-only" and only contains a function.json. The resource is an App Service and it has a couple of functions. There is no link to any git repository in properties.
Read-only Functions would be compiled and published (e.g. through Visual Studio or a CI/CD pipeline.) The Azure Functions Portal engineers are working on a new, improved experience for this but for now, if your Function app has a deployment source configured, you can view it from the Portal in two ways from your Function app:
Platform Features > Deployment Options.
Platform Features > Resource Explorer. In the file tree on the lefthand side, find your Function app's name, and under that, sourcecontrols. Click to expand in the righthand window.
If your Function app doesn't have a deployment source configured (e.g. your team has been publishing code manually) then things get harder. Depending on how your company has set up their source control and what you already have access to, the function.json you see might help: the entryPoint property in a build-generated function.json will give you the full assembly name of that function (e.g. VSSample.HelloSequence.Run). That or the assembly name of the uploaded DLL in the scriptfile property might help you locate the project.
Good luck! Keep posting if you have further questions; we're here to help.
AFAIK, if we create the azure function in the Visual Studio and publish it to Azure(there may be other ways), it will appear in the situation you described like the screenshot.
Actually, the code is existing in the portal, but the code has been compiled, you could access it in the Platform features -> Advanced tools (Kudu) -> Debug console.
If you want to get the .cs file, I think you should ask it for your coworkers, there will not be in azure.
You said that the Azure function is listed as "read-only". Did you check from the Application Settings menu if you can change the Azure function app edit mode to Read/Write?

Resources