Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,211 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Not getting the logger information in the console output - Service Bus Trigger
Running Locally
host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
}
}
Function.cs
public class Function1
{
private readonly ILogger<Function1> _logger;
public Function1(ILogger<Function1> log)
{
_logger = log;
}
[FunctionName("Function1")]
public void Run([ServiceBusTrigger("demotopic", "demosubsn", Connection = "SBConnection")]string mySbMsg)
{
_logger.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
}
Output:
Functions:
Function1: serviceBusTrigger
For detailed output, run func with --verbose flag.
[2023-03-23T07:40:28.225Z] Host lock lease acquired by instance ID '<Some_Id>'.
[2023-03-23T07:40:31.148Z] Executing 'Function1' (Reason='(null)', Id=
<Some_Id>)
[2023-03-23T07:40:31.150Z] Trigger Details: MessageId:
<Some_Id>, SequenceNumber: 7, DeliveryCount: 1, EnqueuedTimeUtc: 2023-03-23T07:40:31.4090000Z, LockedUntilUtc: 2023-03-23T07:41:31.4560000Z, SessionId: (null)
[2023-03-23T07:40:40.968Z] Executed 'Function1' (Succeeded, Id=
<Some_Id>, Duration=9865ms)
I'm not getting the message that is
C# ServiceBus topic trigger function processed message: {mySbMsg}
Resolution:
I'm missing the ILogger Class in the Function declaration.
public void Run([ServiceBusTrigger("demotopic", "demosubsn", Connection = "SBConnection")]string mySbMsg, ILogger _logger)