在同一个Azure功能应用程序下部署多个功能无法正常工作 [英] Deploying multiple function under same azure function app not working

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

问题描述

尝试在同一个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,Timer等),请确保已在启动代码中调用了扩展的注册方法(例如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功能应用程序服务下部署这些功能时将其用作工作功能的方法.

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

推荐答案

我不同意 Marc的答案.尽管它可能会偏离已记录的标准,但是从体系结构的角度来看,在同一App Service下包含多个相关功能非常好.使用服务主体机密和对象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作为单独的函数,但是对所有三个都使用一个SINGLE host.json.请注意:您需要在一个文件中包含所有三个函数的主机信息.然后,部署后,您将在单个应用程序服务下看到多种功能.同样,在门户网站上,单击资源后,您将被重定向到App Service仪表板,然后在功能"选项卡下,您可以分别访问每个功能.

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.

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

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