![](/img/trans.png)
[英]POPULAR REACT ISSUE : How to run docker container serving a reactjs app in Azure using docker-compose?
[英]docker-compose to run Azure Functions locally
我们正在构建一个系统,一些客户将在 Azure 中运行,一些客户将通过 docker-compose 在他们自己的硬件上运行在 Docker 中。 我们的微服务基于 Azure 函数。
我编写了一个 docker-compose 文件来设置各种图像(网站,Azure 函数和 RabbitMQ)
docker-compose 看起来像这样(简化):
version: "3"
services:
abmicroservice:
build:
context: ./AbMicroservice
depends_on:
- rabbitmq
当 docker-compose 启动时,当 Azure Function 项目启动时出现此错误:
abmicroservice_1 | 未找到工作职能。 尝试公开您的工作类别和方法。 如果您使用绑定扩展(例如 Azure 存储、ServiceBus、计时器等),请确保您已在启动代码中调用了扩展的注册方法(例如 builder.AddAzureStorage()、builder.AddServiceBus( )、builder.AddTimers() 等)。
但是当我使用 func.exe 工具或 Visual Studio Debug 运行相同的 Azure Function 时,它运行良好。
我猜这个问题是我的各种 host.json 等和 docker-compose.yml 中的设置。
我的 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(查看 function.json 并且“连接字符串”的值应该是连接字符串的名称)
{ "scriptFile": "__init__.py", "bindings": [ { "name": "msg", "type": "serviceBusTrigger", "direction": "in", "queueName": "nameOfTheQue", "connection": "connectionVariable" } ] }
这意味着您的 docker 应该有一个带有连接字符串的环境变量“connectionVariable”(在本例中为服务总线)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.