admin管理员组文章数量:1026989
I'm currently trying to deploy the most basic code Visual studio creates for an azure function using a service bus trigger. Locally works correctly but when I deploy it to azure it doesn't seems to do anything, and if I try to excecute it manually i get the following error:
2024-11-15T21:35:52Z [Information] Received HTTP response headers after 102.8069ms - 200
2024-11-15T21:35:52Z [Information] End processing HTTP request after 111.4159ms - 200
2024-11-15T21:35:52Z [Information] Call failed with gRPC error status. Status code: 'FailedPrecondition', Message: 'LockToken 00000000-0000-0000-0000-000000000000 not found.'.
2024-11-15T21:35:52Z [Error] Function 'FunctionSB', Invocation id 'c8144425-6892-40fc-a415-7f235d053743': An exception was thrown by the invocation.
I'm using this variable by declaring it in the Environment variables -> Connection Strings as the image bellow shows.
As I said the code is the basic one:
[Function(nameof(FunctionSB))]
public async Task Run(
[ServiceBusTrigger("visionsystemmessages")]
ServiceBusReceivedMessage message,
ServiceBusMessageActions messageActions)
{
string content = message.Body.ToString();
// Complete the message
await messageActions.CompleteMessageAsync(message);
Console.WriteLine("Success start");
}
Am I missing anything? if I didn't gave enough info please ask me
I'm currently trying to deploy the most basic code Visual studio creates for an azure function using a service bus trigger. Locally works correctly but when I deploy it to azure it doesn't seems to do anything, and if I try to excecute it manually i get the following error:
2024-11-15T21:35:52Z [Information] Received HTTP response headers after 102.8069ms - 200
2024-11-15T21:35:52Z [Information] End processing HTTP request after 111.4159ms - 200
2024-11-15T21:35:52Z [Information] Call failed with gRPC error status. Status code: 'FailedPrecondition', Message: 'LockToken 00000000-0000-0000-0000-000000000000 not found.'.
2024-11-15T21:35:52Z [Error] Function 'FunctionSB', Invocation id 'c8144425-6892-40fc-a415-7f235d053743': An exception was thrown by the invocation.
I'm using this variable by declaring it in the Environment variables -> Connection Strings as the image bellow shows.
As I said the code is the basic one:
[Function(nameof(FunctionSB))]
public async Task Run(
[ServiceBusTrigger("visionsystemmessages")]
ServiceBusReceivedMessage message,
ServiceBusMessageActions messageActions)
{
string content = message.Body.ToString();
// Complete the message
await messageActions.CompleteMessageAsync(message);
Console.WriteLine("Success start");
}
Am I missing anything? if I didn't gave enough info please ask me
Share Improve this question asked Nov 15, 2024 at 21:45 qwertyuiop lkjhgfdsaqwertyuiop lkjhgfdsa 213 bronze badges 3- "excecute it manually" what does that mean? Do you add a message to the queue to trigger your function or something else? – Sean Feldman Commented Nov 15, 2024 at 21:54
- @qwertyuiop lkjhgfdsa Can you share the local.ettings.json file? – Dasari Kamali Commented Nov 16, 2024 at 6:45
- @qwertyuiop lkjhgfdsa Is the trigger is ServiceBusQueue trigger or topic trigger Function? – Dasari Kamali Commented Nov 16, 2024 at 17:02
1 Answer
Reset to default 1The issue is related to misconfiguration in the Azure Function App setup or permissions in the Service Bus namespace.
- Verify that the queue connection string in Azure Function App > App Settings.
- Ensure that the Queue connection string has Manage, Send, and Listen permissions for the Service Bus namespace.
After deployment, make sure to add the Service Bus queue connection string in the function app > Environment variables > App settings as shown below.
"ServiceBusQueue": "<queueconnestring>"
Now send a message to the Service Bus Queue as shown below.
After some time you can directly see the logs in the Invocation section in function app as shown below.
Code :
using System;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace FunctionApp3
{
public class Function1
{
private readonly ILogger<Function1> _logger;
public Function1(ILogger<Function1> logger)
{
_logger = logger;
}
[Function(nameof(Function1))]
public async Task Run(
[ServiceBusTrigger("kamqueue", Connection = "ServiceBusQueue")]
ServiceBusReceivedMessage message,
ServiceBusMessageActions messageActions)
{
string content = message.Body.ToString();
await messageActions.CompleteMessageAsync(message);
Console.WriteLine("Success start");
}
}
}
local.settings.json :
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"ServiceBusQueue": "<queueconnestring>"
}
}
I'm currently trying to deploy the most basic code Visual studio creates for an azure function using a service bus trigger. Locally works correctly but when I deploy it to azure it doesn't seems to do anything, and if I try to excecute it manually i get the following error:
2024-11-15T21:35:52Z [Information] Received HTTP response headers after 102.8069ms - 200
2024-11-15T21:35:52Z [Information] End processing HTTP request after 111.4159ms - 200
2024-11-15T21:35:52Z [Information] Call failed with gRPC error status. Status code: 'FailedPrecondition', Message: 'LockToken 00000000-0000-0000-0000-000000000000 not found.'.
2024-11-15T21:35:52Z [Error] Function 'FunctionSB', Invocation id 'c8144425-6892-40fc-a415-7f235d053743': An exception was thrown by the invocation.
I'm using this variable by declaring it in the Environment variables -> Connection Strings as the image bellow shows.
As I said the code is the basic one:
[Function(nameof(FunctionSB))]
public async Task Run(
[ServiceBusTrigger("visionsystemmessages")]
ServiceBusReceivedMessage message,
ServiceBusMessageActions messageActions)
{
string content = message.Body.ToString();
// Complete the message
await messageActions.CompleteMessageAsync(message);
Console.WriteLine("Success start");
}
Am I missing anything? if I didn't gave enough info please ask me
I'm currently trying to deploy the most basic code Visual studio creates for an azure function using a service bus trigger. Locally works correctly but when I deploy it to azure it doesn't seems to do anything, and if I try to excecute it manually i get the following error:
2024-11-15T21:35:52Z [Information] Received HTTP response headers after 102.8069ms - 200
2024-11-15T21:35:52Z [Information] End processing HTTP request after 111.4159ms - 200
2024-11-15T21:35:52Z [Information] Call failed with gRPC error status. Status code: 'FailedPrecondition', Message: 'LockToken 00000000-0000-0000-0000-000000000000 not found.'.
2024-11-15T21:35:52Z [Error] Function 'FunctionSB', Invocation id 'c8144425-6892-40fc-a415-7f235d053743': An exception was thrown by the invocation.
I'm using this variable by declaring it in the Environment variables -> Connection Strings as the image bellow shows.
As I said the code is the basic one:
[Function(nameof(FunctionSB))]
public async Task Run(
[ServiceBusTrigger("visionsystemmessages")]
ServiceBusReceivedMessage message,
ServiceBusMessageActions messageActions)
{
string content = message.Body.ToString();
// Complete the message
await messageActions.CompleteMessageAsync(message);
Console.WriteLine("Success start");
}
Am I missing anything? if I didn't gave enough info please ask me
Share Improve this question asked Nov 15, 2024 at 21:45 qwertyuiop lkjhgfdsaqwertyuiop lkjhgfdsa 213 bronze badges 3- "excecute it manually" what does that mean? Do you add a message to the queue to trigger your function or something else? – Sean Feldman Commented Nov 15, 2024 at 21:54
- @qwertyuiop lkjhgfdsa Can you share the local.ettings.json file? – Dasari Kamali Commented Nov 16, 2024 at 6:45
- @qwertyuiop lkjhgfdsa Is the trigger is ServiceBusQueue trigger or topic trigger Function? – Dasari Kamali Commented Nov 16, 2024 at 17:02
1 Answer
Reset to default 1The issue is related to misconfiguration in the Azure Function App setup or permissions in the Service Bus namespace.
- Verify that the queue connection string in Azure Function App > App Settings.
- Ensure that the Queue connection string has Manage, Send, and Listen permissions for the Service Bus namespace.
After deployment, make sure to add the Service Bus queue connection string in the function app > Environment variables > App settings as shown below.
"ServiceBusQueue": "<queueconnestring>"
Now send a message to the Service Bus Queue as shown below.
After some time you can directly see the logs in the Invocation section in function app as shown below.
Code :
using System;
using System.Threading.Tasks;
using Azure.Messaging.ServiceBus;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;
namespace FunctionApp3
{
public class Function1
{
private readonly ILogger<Function1> _logger;
public Function1(ILogger<Function1> logger)
{
_logger = logger;
}
[Function(nameof(Function1))]
public async Task Run(
[ServiceBusTrigger("kamqueue", Connection = "ServiceBusQueue")]
ServiceBusReceivedMessage message,
ServiceBusMessageActions messageActions)
{
string content = message.Body.ToString();
await messageActions.CompleteMessageAsync(message);
Console.WriteLine("Success start");
}
}
}
local.settings.json :
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"ServiceBusQueue": "<queueconnestring>"
}
}
本文标签: cAzure Function using ServiceBus triggerStack Overflow
版权声明:本文标题:c# - Azure Function using ServiceBus trigger - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745669589a2162381.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论