serverless-azure-functions
serverless-azure-functions copied to clipboard
ServiceBusTrigger values in function.json not as defined in yml
This is a Bug Report
Description
-
What went wrong? the deployed function.json does not include the queueName or connection in the serverless.yml. Instead it includes the queueName and connection as defined in the c# ServiceBusTrigger attribute
-
What did you expect should have happened? I expected the serverless plugin to set the values in function.json to whats defined in the yaml
-
What was the config you used?
serverless.yml:
service: oscarsinkfunc-app
# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
frameworkVersion: '2'
provider:
name: azure
region: West Europe
runtime: dotnet3.1
prefix: "ianr"
subscriptionId: ...redacted...
stage: dev
environment:
SERVICE_BUS_CONNECTION: '...redacted...'
plugins:
- serverless-azure-functions
functions:
oscarsinkfunc:
handler: src/handlers/oscarsinkfuncclass.main
events:
- serviceBus: true
name: message
queueName: myqueue
accessRights: listen
connection: SERVICE_BUS_CONNECTION
c#:
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using System;
namespace myNamespace
{
public static class oscarsinkfuncclass
{
[FunctionName("oscarsinkfuncname")]
public static void Run(
[ServiceBusTrigger("blahqueue", Connection = "blahconnection")]
string message,
ILogger log)
{
log.LogInformation($"C# ServiceBus queue trigger function {nameof(oscarsinkfuncclass)} processed message: {message ?? "(null)"}");
}
Resulting function.json (taken from the azure portal via func -> code+test):
{
"generatedBy": "Microsoft.NET.Sdk.Functions-3.0.9",
"configurationSource": "attributes",
"bindings": [
{
"type": "serviceBusTrigger",
"connection": "blahconnection",
"queueName": "blahqueue",
"isSessionsEnabled": false,
"name": "message"
}
],
"disabled": false,
"scriptFile": "../bin/OscarSinkFunctionApp.dll",
"entryPoint": "myNamespace.oscarsinkfuncclass.Run"
}
- What stacktrace or error message from your provider did you see? No error - deploys fine but the queueName and connection strings are obviously wrong.
Similar or dependent issues:
- #485
Additional Data
- Serverless Framework Version you're using: 2.10.0
- Serverless CLI Version you're using:
- Serverless Azure Plugin Version you're using: 2.1.0
- Operating System: Windows 10
- Stack Trace: n/a
- Provider Error messages: n/a
additionally, setting the values to null in c# does not work
[ServiceBusTrigger(null, Connection = null)]
the function.json (from the zip in .serverless) is missing the values entirely:
"bindings": [
{
"type": "serviceBusTrigger",
"isSessionsEnabled": false,
"name": "message"
}
],
FYI the workaround I'm using is to use the %% syntax for the c# queue prop:
[ServiceBusTrigger("%SERVICE_BUS_QUEUE_NAME%", Connection = "SERVICE_BUS_CONNECTION")]
and then define the queue name as env var in the serverless.yml:
environment:
SERVICE_BUS_CONNECTION: '...redacted...'
SERVICE_BUS_QUEUE_NAME: '...redacted...'