Azure / Azure/azure-functions-core-tools

Generated function.json missing direction out

Open
#3,157 18 comments 0 reactions 0 assignees View on GitHub
Needs: Attention :wave:
Dominant language
C#
Stars
1.5k
Forks
498
Avg merge
4d 20h
Merged PRs (30d)
14

Description

**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:_**

```
using Newtonsoft.Json.Linq;
using IoTHubTrigger = Microsoft.Azure.WebJobs.EventHubTriggerAttribute;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;

public static class IoTHubToCosmosDB
{
[FunctionName("IoTHubToCosmosDB")]
public static void Run(
[IoTHubTrigger("eventHubName", Connection = "connectionString", ConsumerGroup = "consumerGroup")] string myIoTHubMessage,
[CosmosDB("databaseName", "collectionName", ConnectionStringSetting = "connectionString", CreateIfNotExists = true, PartitionKey = "/deviceId")] out object dataDocument,
ILogger log)
{
log.LogInformation($"C# trigger Azure function processed a IoT Hub message: {myIoTHubMessage}");
var parsedMessage = JObject.Parse(myIoTHubMessage);
dataDocument = parsedMessage;
}
}
```

**_Bindings from generated function.json:_**
```
"bindings": [
{
"type": "eventHubTrigger",
"connection": "connectionString",
"consumerGroup": "consumerGroup",
"eventHubName": "eventHubName",
"name": "myIoTHubMessage"
},
{
"type": "cosmosDB",
"connectionStringSetting": "connectionString",
"createIfNotExists": true,
"partitionKey": "/deviceId",
"databaseName": "databaseName",
"collectionName": "collectionName",
"useMultipleWriteLocations": false,
"useDefaultJsonSerialization": false,
"name": "dataDocument"
}
],
```

**Environment**
_Azure Toolkit for Rider_ 3.50.0.1314-2021.3
_Azure Functions Core Tools_ 4.0.4785
_JetBrains Rider_ 2021.3.4

Contributor guide

Open the contributing guide

Research direction

Start by tracing how the C# code's CosmosDB out parameter becomes the generated function.json bindings; the issue's sample shows the missing field in the Cosmos binding. Compare the generated binding with the declared out object dataDocument and verify deployment output with Azure Functions Core Tools. Done means generated Cosmos bindings include direction: out.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, csharp
Domain
cli, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.