Azure / Azure/azure-functions-host

Event hub trigger does not work using RBAC for AzureWebJobsStorage

Open
#9,612 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2k
Forks
482
Avg merge
2d 10h
Merged PRs (30d)
36

Description

#### Investigative information

Please provide the following:

- Timestamp: 2023-10-13T13:36:38.4041155Z (of error in log)
- Function App version: ~4
- Invocation ID: 2ebd3d46-96c4-4b05-912b-910ea5d04ebf (a successful invocation after changing app setting format)
- Region: Norway East

#### Repro steps

Provide the steps required to reproduce the problem:

1. Create an Azure IoT Hub. Enable the fallback route
2. Create an Azure function app with an EventHubTrigger function listening to the built in endpoint of the IoT Hub. Use a connection string for the iothubowner policy for the trigger connection
3. Set up storage for the function app according to this guide: https://techcommunity.microsoft.com/t5/apps-on-azure-blog/use-managed-identity-instead-of-azurewebjobsstorage-to-connect-a/ba-p/3657606
4. Create a device in the IoT hub and send a D2C message from the device to the hub

#### Expected behavior

The function should trigger

#### Actual behavior

The function does not trigger, and errors are found in the logs
System.ArgumentNullException
Error indexing method 'IoTHubTrigger' Value cannot be null. (Parameter 'connectionString')
Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse

#### Known workarounds

Changing the appsettings to AzureWebJobsStorage+Access Key instead of AzureWebJobsStorage__accountname+storage name seems to make the function trigger again. However, RBAC should be preferred to minimize the use of secrets

#### Related information

Using .NET 6, and dotnet runtime

```csharp
[FunctionName("IoTHubTrigger")]
public async Task Run([EventHubTrigger("messages/events",
Connection = "EventHubConnectionAppSetting", ConsumerGroup = "services")]
EventData[] myEventHubMessages)
{
// this does not trigger
}
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the C# IoTHubTrigger example with the RBAC-based AzureWebJobsStorage settings described in the issue, then inspect the indexing failure and null connectionString error. Compare it with the working AzureWebJobsStorage+Access Key format. Done means the EventHubTrigger responds to a device-to-cloud message while retaining RBAC-based storage access.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.