Deploying a precompiled f# function to Azure Functions v2 - azure

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?

Related

Authorization:REDACTED when executing an Azure Function

I am observing Authorization:REDACTED in the log stream attached to my Azure Function.
Context:
Note, that I can execute the same function successfully when I run the Function App in the debugger within my Visual Studio session, using local host.
Details:
x-ms-return-client-request-id:true
User-Agent:azsdk-net-Storage.Blobs/12.13.0,(.NET 6.0.11; Microsoft Windows 10.0.14393)
x-ms-date:Wed, 01 Feb 2023 19:42:49 GMT
Authorization:REDACTED
client assembly: Azure.Storage.Blobs
The Azure Function was deployed using Pulumi.
FUNCTIONS_EXTENSION_VERSION : ~4
Verifications:
I verified that the Azure Function's URL referenced in my client app is valid and matches the URL in the Azure portal for the Azure Function I want to invoke
I executed the Azure Function from local host without issue.
Please check the below findings if that helps to fix your issue:
When I run the Pulumi Serverless Function (CSharp) in Visual Studio locally, I got the below output:
Not Sure the cause of the issue because I tried Pulumi Stack for the 1st time.
And I have identified the similar issue registered in MS Q&A Forum #1163056 and the user #MayankBargali-MSFT given the accepted solution to check the local storage emulator is running on the specified ports each with each Storage object such as Blob, Queue, Table.

AzureBlobCredentialMissing Error only occurs when triggered, versus no error in Debug

I get the following error in a pipeline that's first activity is to do a lookup on a storage container to get the contents of a file. When I test the connectionns, linked server, datasets or debug the pipeline I do not receive any errors. However when the pipeline is triggered by the storage event, it throws this error:
ErrorCode=AzureBlobCredentialMissing,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Please provide either connectionString or sasUri or serviceEndpoint to connect to Blob.,Source=Microsoft.DataTransfer.ClientLibrary,'
As per your scenario, where the debug is successful but the trigger runs failing. This make me assume that your dev changes have not been published which is why the trigger run fails. In simple terms the most recent published version of your linked service is different than that of your development version which haven't been published.
In case if you are using Source control then I would recommed following this tutorial for best practices - Automated publishing for continuous integration and delivery
If you are using CI-CD, then the issue might indeed cause by the DevOps pipeline not overriding the linked service parameters. Try redeploying the resource bye following below step and it should work as expected. (Linked service parameters had to be overwritten on the Azure resource template)
For example, if you have a linked service such as below:
Then you will still have to add below values into the overrideParameters section of the AzureResourceManagerTemplateDeployment task.

Azure function error: app does not support remote build as it was created before August 1st, 2019

I am trying to deploy my azure function with VS code using func azure functionapp publish nhtsa --build remote and I am getting below error.
Remote build is a new feature added to function apps.
Your function app does not support remote build as it was created before August 1st, 2019.
Please use '--build local' or '--build-native-deps'.
For more information, please visit https://aka.ms/remotebuild
I thought it's because of the storage account access -tier and access level, so I change my storage account tier to cool and container access to public, and I deploy the function again, and I'm still getting the error.
Any idea how I can resolve this issue.
Thanks
As the error specified, it is not supported for function app created before August 1, 2019 (see documentation):
If you're having issues with remote build, it might be because your app was created before the feature was made available (August 1, 2019). Try creating a new function app, or running az functionapp update -g <RESOURCE_GROUP_NAME> -n <APP_NAME> to update your function app. This command might take two tries to succeed.
I had the same issue the solution was to fix the "defaultAction"
It should be "Allow"

'az functionapp deployment' reports success, but Functions view in Azure is empty

I have 1 function app that for some reason doesn't want to deploy (All 30 other function apps I manage deploy fine with the same ZipDeploy method).
After running the following AzureCLI command to deploy to an existing consumption based function app:
az functionapp deployment source config-zip --resource-group $resourceGroupName --name $functionAppName --src $artifactPath
This returns a successful deployment result (see bottom of question for the full JSON result), however looking in the Functions blade for the function app, this is empty:
My question is this - what am i doing wrong here? Why does deploying a function via AzureCLI fail?
A bit of background:
Functions we're using are precompiled C#
The function apps are created by Terraform
This function is a service bus trigger function that has the same host.json/functions.json as other successful function deployments
Things i've tried so far:
Deployed via the 'Publish' route in Visual Studio 2019 as a test. This works successfully.
Running the AzureCLI command locally, same result
Checked the function code structure against the suggested folder structure, this complies
Compared the zipped artifact i'm deploying against other successful deployment zips. Same structure as working functions.
Full logging from the AzureCLI command:
Setting SCM_DO_BUILD_DURING_DEPLOYMENT to false
Waiting SCM site to be updated with the latest app settings
Getting scm site credentials for zip deployment
Starting zip deployment. This operation can take a while to complete ...
Deployment endpoint responded with status code 202
Full JSON response from the AzureCLI command:
active : True
author : N/A
author_email : N/A
complete : True
deployer : ZipDeploy
end_time : 23/09/2020 16:32:28
id : 02c6219516244615beca1c126749baa1
is_readonly : True
is_temp : False
last_success_end_time : 23/09/2020 16:32:28
log_url : https://xxxx.scm.azurewebsites.net/api/deployments/latest/log
message : Created via a push deployment
progress :
provisioningState :
received_time : 23/09/2020 16:31:55
site_name : xxxx
start_time : 23/09/2020 16:31:55
status : 4
status_text :
url : https://xxxx.scm.azurewebsites.net/api/deployments/latest
EDIT 1: Here are the contents of the wwwroot folder for anyone interested - they follow the same structure as other functions we have (which deploy fine and display in the Functions view in the portal):
After long last we found out the cause of why the function app didn't deploy.
Turns out it deployed fine (the files were deployed in the right place) - it's just that the function runtime crashed on startup.
We found the usage of 'builder.Services.AddMvc()' caused this issue:
Which makes sense, given Azure Functions aren't Mvc. Derp!
We removed this line and voila, no more issues.
I might know what's wrong during your ZipDeploy process. Maybe the way you get your zip folder is wrong.
As I said, you can check if the destiny function app name is correct, and check if the content in https://<functionAppName>.scm.azurewebsites.net/DebugConsole -->site-->wwwroot(kudu) is correct.
The correct step of ZipDepoly is:
1. Click Publish option just like deployed via the 'Publish' route in Visual Studio 2019
2. Choose folder to create publish file.
3. Compress the publish file content you got from last step. The structure of publish file is same as in docs.
Publish.zip
| - bin
| - host.json
| - FunctionName
| | - function.json
4. Publish that zip file by your command. And the content of wwwroot should be same as publish file:

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