Azure / Azure/azure-functions-host
ServiceBus trigger with managed identity doesn't wake up consumption plan function apps when Connection isn't explicitly defined
- Dominant language
- C#
- Stars
- 2k
- Forks
- 482
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 38
Description
This is for in-process v4 function apps, I'm unsure whether this also applies to the isolated variant.
When a Service Bus trigger is defined with a connection via managed identity, the function app doesn't get woken up by Azure when the Connection property is **not** defined in the trigger attribute, despite the trigger working fine when the function app is active.
#### Investigative information
- Timestamp: 2022-03-22T02:58:56.0115521Z
- Invocation ID: 6309186b-c3f9-43f1-abeb-6f6385cd7c10 (one of many)
- Region: West Europe
#### Repro steps
1. Create a function app with a service bus trigger via managed identity without specifying the Connection property
2. Publish to Azure
3. Wait for the function app to go inactive
4. Post a message to the service bus queue
#### Expected behavior
The function app should get woken up and the service bus triggered function should get triggered.
As far as I know, the Connection property was never mandatory for triggers that use connection strings, so this feels like an invisible breaking change when moving to managed identity based connections.
#### Actual behavior
The function app does not get woken up, and the service bus triggered function is not triggered.
#### Known workarounds
Define the Connection property that points to the name of the configuration (and gets resolved to `__fullyQualifiedNamespace`).
#### Related information
I've noticed that the generated function.json only includes the connection field if the Connection property is defined. This makes me believe that the default value "ServiceBus" is only considered in the functions runtime, and not in the Azure scale controller for function apps.
Source
```cs
[FunctionName("ServiceBusTest")]
public Task Run([ServiceBusTrigger("queue-name")] QueueMessage message)
{
// This doesn't get triggered if the function app is inactive
}
```
The second trigger generates a function.json file **with** the connection property, because it's now explicitly defined:
```cs
[FunctionName("ServiceBusTest2")]
public Task Run([ServiceBusTrigger("queue-name", Connection = "ServiceBus")] QueueMessage message)
{
// This does get triggered if the function app is inactive
}
```
Contributor guide
Research direction
Start by comparing the generated function.json for the two ServiceBusTrigger declarations, then trace how the Functions runtime and Azure scale controller consume the connection metadata. Done means a managed-identity Service Bus trigger wakes an inactive consumption-plan app without an explicit Connection, while the explicit-Connection case continues to work.
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
- 42/100