Azure Function App 2.0 unable to deploy properly - azure

I'm trying to deploy my azure function (.NET Core 2.1) using zip based method but when I check the portal, Azure function always creates a sample run.csx to execute instead of executing my .cs file which contains run method tagged with function name.
Any ideas why is it unable to initialize the function after deployment?
I've tried:
Pushing my deployment zip while a timer trigger function app with the same name existing.
Deleting the above timer trigger function app then deploying the code.
In 1st case, previously existing run.csx is present in place of our function app.
In 2nd case, no function gets initialized.
Edit 1:
File structure:
|__TimerFunc/ [TimerFunc.cs, function.json]
|__project.csproj
|__host.json

Only uploading the zip file is not enough, you must create the following App Setting:
WEBSITE_RUN_FROM_PACKAGE
and add the value
1
More info:
https://learn.microsoft.com/en-us/azure/azure-functions/run-functions-from-deployment-package

Related

Durable function template missing from function templates list

I've created a web app and first durable function in it. Ran npm install durable-functions at the root of the directory of the app. But trying to create an orchestrator/second function app I see this warning in my portal. I do not see the durable function template in the list of azure function templates to create. How do I get this option back? Please help. Looks like I don't have the whole collection of extensions bundle. Where should this be installed?
This is what my host.config looks like. The extension bundle supported was 1* to 2.0 after running npm install durable-functions but I've updated it to 2* to 3.0 after reading https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-register
This is my package.json file
I recreated a new storage account and added application strings to my function app AzureWebJobsStorage and AzureWebJobsDashboard with value from the connection string for the new storage account. Restarted my function app.

How do I get into the folder of a Web App in Azure

Recently I am trying to use:
func azure functionapp publish WebAppName --publish-local-settings -i
to publish local.settings.json to a web app (actually an Azure function) but I get this error message:
Unable to find project root. Expecting to find one of host.json in project root.
I have logged in to Azure with az login but it looks like I need to get into the folder where I have deployed the Azure function where all those json files are.
A little background, we are using Octopus Deploy to deploy to an Azure function. After the deployment, we want to add a step so that the local.setting.json will be used to populate app settings.
So how do we change the current folder to be in the Azure function root where all those json files are?
Thanks a lot in advance!
You need to go to your local function project folder to run the command, for example, my function project is under MyFunctionProj folder.
Execute the command
func azure functionapp publish tonyfunc --publish-local-settings -i --publish-settings-only
By the way, if you just want to update the settings, you need add --publish-settings-only parameter.
Reference:
Core Tools development

Azure Functions App is Read Only after publishing

I have several Azure Functions Apps (c#, javascript and python) and after some time they were all randomly set to Read Only mode. The strange thing is that only one of these 3 function apps were updated before this happened. I know that this is not necessarily a problem, but I want to be able to make edits from the portal.
I can't open App Service Editor
I can't set the app to Read/Write from Function App Settings -> Function app edit mode
I also tried using "func azure functionapp publish myAzFuncAppName --nozip", but with the same result
Of course. Please notice that if the function is 'deployed' to Azure, what will be deployed is the compiled file.
For example, if you deploy C# function app, what will be deployed is the dll file. So this is why it is readonly.
Changes to the code should be done before compiling them into corresponding 'cannot be edited' files, which requires special attention.
But for the modification of the declarative part and the configuration part of the function, this is possible, the specific steps are as follows:
Declarative part:
Then click Debug Console > cmd:
Go to site\wwwroot[yourfunctionname], and there will be a function.json.
Click the 'pen' to edit and don't forget to save.
Configuration part:
You can change the settings from Azure Portal or by editing the application settings. FUNCTION_APP_EDIT_MODE allows values readwrite and readonly, a
Just deleted the Azure Function App, created a new one, transferred the code in the new one and deployed -> still read only, but now I was able to open "App Service Editor" and remove "generated by..." from function.json and then set "Read/Write" from Function App Settings -> Function app edit mode.
Still... I can't see/edit the code of the function, only of function.json and if I redeploy using Azure extensions of Visual Code or powershell with --nozip attribute, the "generated bla bla" appears again :(
When the application runs from package, the files are loaded from that package. Hence those files are not editable.
You need to set WEBSITE_RUN_FROM_PACKAGE : 0 in app settings and redeploy the application again to make the function app editable.
refer https://social.msdn.microsoft.com/Forums/en-US/972d843c-8bdc-4cfc-9c6d-263df196d37c/azure-function-app-readonly-mode?forum=AzureFunctions
UPDATED:
You can deploy functionapp through command line from visual studio code. Try below command.
func azure functionapp publish --nozip
The nozip flag would set Run-From-Package mode off .
you can access other information regarding that command with func azure functionapp publish --help

Deploying a precompiled f# function to Azure Functions v2

I have created a f# project that contains two functions. I can run theses locally and when I do func start (or start debug with F5 it in VS Code). One of the two functions copy data from one azure storage container to another and the other function copies some data from a DB and puts it in an azure storage container. All this works nicely when I run it locally. Now I would like to deploy these to Azure Functions. I have created a resource group, created the Function app and ensured that the Function App settings indicate that it is a Azure function version 2. When I try to deploy the functions via:
func azure functionapp publish <FUNCTION APP NAME>
The code is uploaded to Azure. And the output is:
Getting site publishing info...
Creating archive for current directory...
Uploading archive...
Upload completed successfully.
Syncing triggers...
In Azure portal under deployment options I see that a deployment has been triggered and looking at the details for the latest one I get:
Mon 09/17 Updating submodules.
Mon 09/17 Preparing deployment for commit id '75833a2816'.
Mon 09/17 Generating deployment script. View Log
Mon 09/17 Running deployment command... View Log
Mon 09/17 Running post deployment command(s)...
Mon 09/17 Syncing 2 function triggers with payload size 317 bytes successful.
Mon 09/17 Deployment successful.
This seems to indicate that two functions have been found and successfully deployed. However, the functions are not listed under the Functions under the Function App. And I have not been able to make successfull calls to them.
Do I have to provide some additional configuration in order to run a F# application as an Azure Function v2?
Here is what I see in the logs for Function App BokioMLDataExtractorFunctionsTest:
CopyImagesToBokioAIStorage: Invalid script file name configuration. The 'scriptFile' property is set to a file that does not exist.
CopyOcrToBokioAIStorage: Invalid script file name configuration. The 'scriptFile' property is set to a file that does not exist.
That is why the two functions are not showing up. Hopefully that helps figure out the issue?

Azure WebJobs SDK ServiceBus connection string 'AzureWebJobsAzureSBConnection' is missing or empty

I created an Azure Function App in Visual Studio 2015. The App has a trigger for service bus queues. The app works perfectly when I run it locally. It is able to read the data from the Service Bus queue (configured via a variable named AzureSBConnection) and log it in my database.
But it gives me the following error when deployed in Azure:
Function ($ServiceBusQueueTriggerFunction) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ServiceBusQueueTriggerFunction'. Microsoft.Azure.WebJobs.ServiceBus: Microsoft Azure WebJobs SDK ServiceBus connection string 'AzureWebJobsAzureSBConnection' is missing or empty.
Note that my connection is called AzureSBConnection and not AzureWebJobsAzureSBConnection. Also, the connection works locally. And finally, the deployed file looks exactly like the local file.
The Visual Studio structure looks like the following:
The function.json file has a bunch of settings as shown below:
Then in the Appsettings.json file, I have the following:
For deploying, I FTPed the files to the D:\home\site\wwwroot location for my Function App in Azure. The final structure in Kudu looks like:
And if I go inside my function folder:
Here is the deployed function.json:
And here is the deployed appsettings:
The deployed json files are exactly the same as the local files. But the deployed version is erroring out because of the missing AzureWebJobsAzureSBConnection. What am I doing wrong?
Only environment variables are supported for app settings and connection strings.
You need to make sure that the environment variable AzureWebJobsAzureSBConnection is set on your Function's app settings in the portal:
and then once there, you need to add the AzureWebJobsAzureSBConnection variable with the proper connection string:
and then you can access this via code by:
Environment.GetEnvironmentVariable(name, EnvironmentVariableTarget.Process);
This will obtain the value from either the appsettings.json or the environment variable depending on where the function is being executed from, (local debugging or deployed on Azure)
It is able to read the data from the Service Bus queue (configured via a variable named AzureSBConnection) But it gives me the following error when deployed in Azure:
After you deployed your application to Azure Function, your application will read the connection string from environment setting. Currently, connection settings in appsettings.json will not update environment setting automatically. We could click [Configure app settings] button as #flyte mentioned to check whether the connection string is configured successfully. If not, you could add it manually in app setting box.
Note that my connection is called AzureSBConnection and not AzureWebJobsAzureSBConnection
Please go to [Integrate] page to check whether the [Service Bus connection] is configured successfully. If not, you could reset it by clicking the [new] link.

Resources