在同一个天蓝色功能应用程序下部署多个功能不起作用 [英] Deploying multiple function under same azure function app not working

查看:10
本文介绍了在同一个天蓝色功能应用程序下部署多个功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试在同一个azure函数应用服务账号下部署3个不同类型的函数(CosmosDBTrigger/TimerTrigger/HttpTrigger),附上文件夹结构供参考.

Trying to deploy 3 functions of different types(CosmosDBTrigger/TimerTrigger/HttpTrigger) in the same azure function app service account, attached the folder structure for reference.

功能未按预期工作,但在成功部署后抛出错误.

Functions are not working as expected but throwing error after successful deployment.

函数 (CopyToQueue) 错误:Microsoft.Azure.WebJobs.Host:错误索引方法CopyToQueue".Microsoft.Azure.WebJobs.Host:无法将参数inputCloudSyncJobModels"绑定到类型 IEnumerable`1.确保绑定支持参数类型.如果您正在使用绑定扩展(例如 Azure 存储、ServiceBus、计时器等),请确保您已在启动代码中调用了扩展的注册方法(例如 builder.AddAzureStorage()、builder.AddServiceBus()、builder.AddTimers() 等).

Function (CopyToQueue) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'CopyToQueue'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'inputCloudSyncJobModels' to type IEnumerable`1. Make sure the parameter Type is supported by the binding. 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.).

       public static async Task Run([**TimerTrigger**(scheduleExpression: "%TimerConfig%")]TimerInfo myTimer,
            [CosmosDB(databaseName: "%DatabaseName%",
            collectionName: "%InputCollection%",
            SqlQuery ="%JobsSelectQuery%",
            ConnectionStringSetting = "CosmosDBConnectionString")]
            IEnumerable<object> **inputCloudSyncJobModels**,
            [Queue(queueName: "%JobsQueueName%", Connection = "StorageConnectionString")] IAsyncCollector<string> outputCloudQueueModels,
            Microsoft.Extensions.Logging.ILogger log, ExecutionContext context)

如果我在不同的单独 azure 函数应用程序服务下部署相同的函数,它们会在没有任何修改的情况下发挥作用.

If I deploy same functions under different individual azure function app services they are working charm without any modifications.

请建议将这些功能部署在同一个 azure function 应用服务下时如何使这些功能正常工作.

Please suggest the way to make these functions as working ones when they are deployed under same azure function app service.

推荐答案

我不同意 Marc 的回答.虽然它可能会偏离文档化的标准,但从架构的角度来看,在同一个应用服务下包含多个相关功能是非常好的.这在使用服务主体机密和对象 ID 时非常方便.

I disagree with Marc's answer. Although it might deviate from the documented standard but from architectural point of view it is very good to include multiple related functions under same App Service. This comes extremely handy while using Service Principal Secrets and Object IDs.

解决方案:

将所有三个函数打包在不同的目录中,即 CosmosDBTrigger、TimerTrigger、HttpTrigger 作为单独的函数,但对所有三个函数使用一个单一的 host.json.请注意:您需要将所有三个函数的主机信息包含在一个文件中.然后在部署后,您将在单个应用服务下看到多个功能.同样在门户中单击资源后,您将被重定向到应用服务仪表板,然后在功能"选项卡下,您可以分别访问每个功能.

Package all three functions in different directories i.e., CosmosDBTrigger, TimerTrigger, HttpTrigger as separate functions but use one SINGLE host.json for all three. Note that: You need to include all three function's host information in one file. Then after deployment you'll see multiple function under single app service. Also in portal after clicking on resource you'll be redirected to App Service dashboard then under Functions tab you can access each function separately.

这篇关于在同一个天蓝色功能应用程序下部署多个功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆