Consumption plan + ServiceBusTrigger + INameResolver = Singleton?
- Dominant language
- PowerShell
- Stars
- 1.1k
- Forks
- 215
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 1
Description
**Describe the bug**
I'm not sure if it's a bug, but it's behavior that I don't understand and I couldn't find documented. It appears that providing a custom `INameResolver` in conjunction with the `ServiceBusTrigger` renders your consumption-based function a singleton. While not using `INameResolver` with a `ServiceBusTrigger` allows your consumption based function to scale based on standard scale out voting mechanisms.
**To Reproduce**
1. Build a Function to look like the following
```C#
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("topic-a", "topic-a-sub-a", Connection = "sbctx", IsSessionsEnabled = false)]string mySbMsg)
...
```
2. Deploy and watch the application scale based on the available workload. Instances added and removed as one would expect.
3. Change that code to do the following:
```C#
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddSingleton();
}
}
...
public class CustomNameResolver : INameResolver
{
public string Resolve(string name) => string.Empty; // More complicated logic would live here, but this is just a no-op to demo
}
...
[FunctionName("Function1")]
public static void Run([ServiceBusTrigger("%prefix%topic-a", "topic-a-sub-a", Connection = "sbctx", IsSessionsEnabled = false)]string mySbMsg)
...
```
4. Deploy and watch the application **not** scale based on the available workload. The instance count stays at **one** regardless of the "health" of the SB subscription that would normally cause scale out votes to take place.
**Expected behavior**
I would have expected the code created in step 3 above to behave identical to the code in step 1 wrt to its impact on scaling. OR I would have expected documentation around the impact on consumption plan scaling with a custom `INameResolver` in this instance.
**Additional context**
I haven't tried this with any other triggers, nor have I tried this on a non-consumption plan. There is a chance that I missed this in documentation (in-code docs or online), but I couldn't find it.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.