【发布时间】:2020-09-14 21:01:16
【问题描述】:
我们正在构建一个系统,一些客户将在 Azure 中运行,而一些客户将通过 docker-compose 在他们自己的硬件上的 Docker 中运行。我们的微服务基于 Azure Functions。
我已经编写了一个 docker-compose 文件来设置各种图像(网站、Azure Functions 和 RabbitMQ)
docker-compose 看起来像这样(简化):
version: "3"
services:
abmicroservice:
build:
context: ./AbMicroservice
depends_on:
- rabbitmq
docker-compose 启动时,Azure Function 项目启动时出现此错误:
abmicroservice_1 |未找到工作职能。尝试制作你的 工作类和方法公开。如果您使用绑定扩展 (例如 Azure Storage、ServiceBus、Timers 等)确保您已调用 启动代码中扩展的注册方法 (例如 builder.AddAzureStorage()、builder.AddServiceBus()、 builder.AddTimers() 等)。
但是当我使用 func.exe 工具或 Visual Studio Debug 运行相同的 Azure Function 时,它运行良好。
我猜问题出在我的各种 host.json 之类以及 docker-compose.yml 中的设置。
My Function 只是一个 hello-world 测试,在 Visual Studio 2019 运行时运行良好:
public static class TriggerFunction
{
[FunctionName("TriggerFunction")]
public static void Run(
[RabbitMQTrigger("hello")] string message,
ILogger log)
{
log.LogInformation($"************* Message received from RabbitMQ trigger: {message}");
}
}
【问题讨论】:
-
您将哪个 Docker 映像用作 Azure Function 应用程序的运行时?作为一种选择,尝试使用“自包含”发布您的函数应用,这可能有助于在容器中运行它
标签: azure docker docker-compose azure-functions azure-functions-runtime