Функция Azure с триггером RabbitMQ — очередь не найдена на локальном хостеC#

Место общения программистов C#
Ответить
Anonymous
 Функция Azure с триггером RabbitMQ — очередь не найдена на локальном хосте

Сообщение Anonymous »

Для локальной разработки я хочу подключить свою функцию Azure к локально работающему экземпляру RabbitMQ и запускать все локально. Но очередь не найдена, хотя я убедился, что она существует (см. скриншот в конце).
Сообщение об ошибке:

Код: Выделить всё

Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ProcessEvent'.  RabbitMQ.Client: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=404, text='NOT_FOUND - no queue 'test' in vhost '/''
Удаленно используя наш центральный экземпляр RabbitMQ, я смог получать события, используя соответствующую строку подключения, но локально что-то идет не так...
Ниже файлы программы и файлы проекта (я использовал VS), а также полный вывод.
Используемые команды:
  • Для запуска RabbitMQ: docker run -it --rm --name RabbitMQ -p 5672:5672 -p 15672:15672 RabbitMQ:4-management
Изменения
  • Изменить 1: Добавлена информация о том, что я запускаю RabbitMQ локально в Docker
  • Изменить 2: Добавлена дополнительная информация о том, как я запускаю RabbitMQ локально
Function.cs

Код: Выделить всё

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Extensions.Logging;

namespace FunctionApp1;

public class Function1
{
private readonly ILogger _logger;
public Function1(ILogger logger)
{
_logger = logger;
}

[Function("ProcessEvent")]
public void Run(
[RabbitMQTrigger("test", ConnectionStringSetting = "RabbitMQConnection")] string message)
{
_logger.LogInformation($"RabbitMQ message received: {message}");

_logger.LogInformation("Message processing completed.");
}
}
local.settings.json

Код: Выделить всё

{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"RabbitMQConnection": "amqp://guest:guest@localhost:5672"
}
}
host.json

Код: Выделить всё

{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
},
"enableLiveMetricsFilters": true
}
}
}

Program.cs

Код: Выделить всё

using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = FunctionsApplication.CreateBuilder(args);

builder.ConfigureFunctionsWebApplication();

builder.Services
.AddApplicationInsightsTelemetryWorkerService()
.ConfigureFunctionsApplicationInsights();

builder.Build().Run();
Файл проекта

Код: Выделить всё



net8.0
v4
Exe
enable
enable














Полный результат:

Код: Выделить всё

'local.settings.json' found in root directory (C:\Users\user\source\repos\FunctionApp1\bin\Debug\net8.0).
Resolving worker runtime to 'dotnet-isolated'.

Azure Functions Core Tools
Core Tools Version:       4.5.0+e74aae22c9630777c9f58354f290a6e214218546 (64-bit)
Function Runtime Version: 4.1044.400.25520

[2025-11-26T09:56:59.113Z] Found C:\Users\user\source\repos\FunctionApp1\FunctionApp1.csproj. Using for user secrets file configuration.
[2025-11-26T09:57:01.068Z] Worker process started and initialized.
[2025-11-26T09:57:01.148Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ProcessEvent'. RabbitMQ.Client: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=404, text='NOT_FOUND - no queue 'test' in vhost '/'', classId=50, methodId=10.
[2025-11-26T09:57:01.166Z] Error indexing method 'Functions.ProcessEvent'
[2025-11-26T09:57:01.168Z] Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ProcessEvent'. RabbitMQ.Client: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=404, text='NOT_FOUND - no queue 'test' in vhost '/'', classId=50, methodId=10.
[2025-11-26T09:57:01.172Z] Function 'Functions.ProcessEvent' failed indexing and will be disabled.
[2025-11-26T09:57:01.176Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[2025-11-26T09:57:01.190Z] The 'ProcessEvent' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'Functions.ProcessEvent'. RabbitMQ.Client: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=404, text='NOT_FOUND - no queue 'test' in vhost '/'', classId=50, methodId=10.

Functions:

ProcessEvent: rabbitMQTrigger

For detailed output, run func with --verbose flag.
[2025-11-26T09:57:06.121Z] Host lock lease acquired by instance ID '000000000000000000000000A4E593EA'.
Конфигурация RabbitMQ

Подробнее здесь: https://stackoverflow.com/questions/798 ... -localhost
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»