Open AllyssaLBatten opened 2 years ago
Just to confirm, Is the write to the cosmos db failing due to the missing "direction" or any other issues you are seeing with the function app?
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.
Correct, the write fails because it is missing the direction. On the Azure portal, when looking at the Integration, there is a warning that says:
The following bindings are missing the required direction property and may have been placed incorrectly: dataDocument. Please update the bindings in your functions.json file.
Otherwise, there are no issues.
Hello all - is there any update on this issue? I am seeing the same problem. The manual fix is to add: "direction": "out",
to the function.json file in the portal's Code + Test screen but that's untenable for every deploy.
This is still an issue. I get
The following bindings are missing the required direction property and may have been placed incorrectly: dataDocument. Please update the bindings in your functions.json file.
Also, the object is unknown.
I am having a similar issue where function core tools generates the wrong binding information where it's emitting the direction
property and instead it puts in access: 1
Function core tools version: 4.0.5198
[FunctionName("ProcessImage")]
public static async Task Run([EventGridTrigger]CloudEvent eventGridEvent,
[Blob(blobPath: "{data.url}", access: FileAccess.Read,
Connection = "dataLakeConnection")] Stream incomingPlate,
ILogger log)
Generates:
"bindings": [
{
"type": "eventGridTrigger",
"name": "eventGridEvent"
},
{
"type": "blob",
"connection": "dataLakeConnection",
"blobPath": "{data.url}",
"access": 1,
"name": "incomingPlate"
}
],
Anyone got the resolution for this? I manually added direction but when I tried to deploy its automatically reverting it to original. "direction":"in"
The direction attribute was removed on purpose as part of https://github.com/Azure/azure-functions-vs-build-sdk/pull/542. You should not be manually adding this attribute to the generated functions.json file.
@gmap3570 Can you be more specific about what exactly is not working due to this change?
We will look into removing the portal warning. But if you are experiencing any other functional issues executing your functions, please open a new issue with the relevant details.
Its not showing proper binding at output. on azure portal it show : 'The following bindings are missing the required direction property and may have been placed incorrectly: outputEvents. Please update the bindings in your functions.json file'
Are there any plans to address this issue. It continues to plague any deployment of an Azure Function using Microsoft.NET.Sdk.Functions.Generator-4.1.1
or Microsoft.NET.Sdk.Functions.Generator-4.2
and that uses a CosmoDB output binding. As it stands, we cannot have a true automated deployment of the Azure function as we have to go to the portal and fix the function.json
by adding the out
parameter manually after every deployment.
No. There are no plans to fix this as the change was made on purpose, as I mentioned in the previous comment.
@nauticalcoder Can you be more specific about what issue are you facing due to this?
@kshyju - I recently (still) encountered the same situation as described by the OP (@AllyssaLBatten), @nauticalcoder and by @gmap3570 in the screenshot provided. When you deploy, the output is "not defined" and you have to manually go in and fix the function.json. As @AllyssaLBatten stated, you must manually go in and add the "direction":"out" key pair.
So if the deployment produced this file:
{
"name": "dataDocument",
"databaseName": "myDatabase",
"collectionName": "myCollection",
"createIfNotExists": true,
"connectionStringSetting": "cosmosdb_DOCUMENTDB",
"partitionKey": "/deviceId",
"type": "cosmosDB"
},
you must modify the JSON by adding:
{
"name": "dataDocument",
"databaseName": "myDatabase",
"collectionName": "myCollection",
"createIfNotExists": true,
"connectionStringSetting": "cosmosdb_DOCUMENTDB",
"partitionKey": "/deviceId",
"type": "cosmosDB",
"direction": "out" <=============
},
(note: the '<=============' arrow above does not actually go in the JSON)
@MysteryAchievement Is your function app working fine for function executions as expected? Are you only seeing the UI issue (as shown in the screenshot above) >
It works after manually making that change. The point I think that everyone is trying to make is this: while you can deploy the Azure Function code via Visual Studio or Rider, function.json
needs manual modification in order to work. Therefore, automated deployment will not work with a CI/CD tool because you have to manually change the function.json
file. The screenshot provided by @gmap3570 is the visual evidence that deployment is broken for output side (in my case, Cosmos DB).
@MysteryAchievement You should not be editing the json file manually to add any attributes. If your function app is not working (to execute function triggers), but the portal UI is not showing the correct thing, we may need to investigate the portal side and fix that.
Does your function app functionally work (functions are executed properly - you could confirm this with your logs) without manually editing the functions.json of the deployed payload?
For what it's worth, on our end it appears the lack of the out
attribute is not actually breaking the function. We thought it was. It does break the Portal UI though which shows the Integration and how the bindings are configured on the function.
Tagging @mattchenderson to help direct this issue for a potential UX fix.
the workaround is to manually edit the function JSON to include a "direction":"in" statement, then do a ZIP file of the build folder (like bin\Release\net6.0\publish* , so the host.json is on the root), then execute az functionapp deployment source config-zip -g resource-group -n app-name --src publish.zip
More info on the ZIP file structure in https://learn.microsoft.com/en-us/azure/azure-functions/deployment-zip-push#deployment-zip-file-requirements
Remember .NET will produce a function.json outside the publish folder. The JSON that must be edited is INSIDE the publish folder, i.e. \net6.0\publish\FunctionName\function.json
"bindings": [
{
"type": "eventGridTrigger",
"name": "eventGridEvent"
},
{
"type": "blob",
"connection": "blobStorageConnection",
"blobPath": "{data.url}",
"access": 1,
"name": "incomingPlate",
"direction": "in"
}
],
Problem
I am attempting to deploy an Azure Function via Rider. The function is triggered by an IoT Hub message, parses the data into json, and writes it to a Cosmos database.
When deploying this function, the generated
function.json
is missing the out direction on the generated Cosmos bindings. Everything else is correct.Below is the C# code and bindings section of
function.json
with sensitive data replaced with placeholder values.C# Code:
Bindings from generated function.json:
Environment Azure Toolkit for Rider 3.50.0.1314-2021.3 Azure Functions Core Tools 4.0.4785 JetBrains Rider 2021.3.4