Tag: azure functions

在本地实现的Azurefunction在云中不起作用

我有以下function,我在本地定义,并能够正常调试它。 [FunctionName(“QueueTrigger”)] public static void DUMMYFUNCTION( [QueueTrigger(“myqueue”, Connection = “AzureWebJobsStorage”)]string myQueueItem, TraceWriter log) { log.Info($”C# function processed: {myQueueItem}”); } 在本地,“AzureWebJobsStorage”在local.settings.json文件中定义,以使用具有“myqueue”的存储帐户。 在Azure上的function设置中,“AzureWebJobsStorage”也设置为正确的连接字符串(与本地设置的字符串相同)。 这意味着,我没有像Azure中那样的问题没有在Azure中执行(无错误) 现在,我使用Visual Studio Team Service在git存储库中托管我的源代码。 我已将部署配置为使用源代码并部署其中包含的function。 我不认为该问题与VSTS有关,因为部署成功执行并且该function显示在我的function列表中: 部署之后,生成文件function.json并具有以下内容: { “generatedBy”: “Microsoft.NET.Sdk.Functions.Generator-1.0.8”, “configurationSource”: “attributes”, “bindings”: [ { “type”: “queueTrigger”, “connection”: “AzureWebJobsStorage”, “queueName”: “myqueue”, “name”: “myQueueItem” }], “disabled”: false, “scriptFile”: “../bin/myAssembly.dll”, “entryPoint”: “myAssembly.MyClass.DUMMYFUNCTION” } 问题是,当我在本地调试它时向队列中添加一个项目时,该函数会被执行,但是当该函数在azure上运行时它不会。 我需要在代码中进行哪些更改才能使其在azure上工作? […]

Azurefunction的事件中心输入绑定

我有一个Azure函数,其输入绑定到事件中心。 public static async Task Run(TraceWriter log, string eventHubMessage) 触发该函数时,默认情况下每次执行会收到多少条消息? 这是1次执行= 1条消息吗? 我已阅读文档并了解您可以在函数的host.json文件中设置这些属性: “eventHub”: { // The maximum event count received per receive loop. The default is 64. “maxBatchSize”: 64, // The default PrefetchCount that will be used by the underlying EventProcessorHost. “prefetchCount”: 256 } maxBatchSize是否意味着我将在1次执行中收到64条消息?

Azure函数用于写入队列 – 我可以设置元数据吗?

我可以从这个页面看到,当它们被用作触发器时,你可以简单地访问队列消息元数据属性,但我想做相反的事情。 我有一个Azure函数,它将消息写入队列,但它当前具有默认的到期时间,我想设置一个更短的过期时间,因此它们只在队列中存在很短的时间。 有没有办法从Azure函数将消息写入队列以设置过期时间? 谢谢 编辑1:有一点需要注意的是,我提前不知道队列的名称。 这是传入消息的一部分,因此将queuename设置为输出绑定的参数,我按照@Mikhail的建议进行了更改。 这是现在的function: #r “Microsoft.WindowsAzure.Storage” #r “Newtonsoft.Json” using System; using Microsoft.WindowsAzure.Storage.Queue; using Newtonsoft.Json; public static void Run(MyType myEventHubMessage, CloudQueue outputQueue, TraceWriter log) { var deviceId = myEventHubMessage.DeviceId; var data = JsonConvert.SerializeObject(myEventHubMessage); var msg = new CloudQueueMessage(data); log.Info($”C# Event Hub trigger function processed a message: {deviceId}”); outputQueue.AddMessage(msg, TimeSpan.FromMinutes(3), null, null, null); } […]

错误索引方法’Class.Method’无法将参数’log’绑定到类型TraceWriter

我已经将一堆我的Azurefunction“升级”为.netstandard 2.0,我收到以下错误: 错误索引方法’Class.Method’无法将参数’log’绑定到类型TraceWriter。 确保绑定支持参数Type。 如果您正在使用绑定扩展(例如ServiceBus,Timers等),请确保您已在启动代码中调用扩展的注册方法(例如config.UseServiceBus(),config.UseTimers()等)。 根据该问题的答案,我确保拥有最新版本的Azure Functions and Web Jobs Tools :它运行的是15.0.40322.0。 不过,我有同样的错误。 我知道运行.netstandard 2.0的Azurefunction处于测试阶段。 我错过了什么?

Azurefunction不通知我的机器人(Bot框架)

我正在使用每X分钟执行一次的Azurefunction(定时器触发function)。 我使用BotFramework制作了一个机器人,我希望每隔x分钟触发一次azurefunction。 当它被触发时,我的机器人必须得到通知。 我有一个输出Bot框架: 这是我的JSON文件: { “bindings”: [ { “name”: “myTimer”, “type”: “timerTrigger”, “direction”: “in”, “schedule”: “0 */1 * * * *” }, { “type”: “bot”, “name”: “message”, “botId”: “Azurefunction”, “secret”: “h3VkHcc_PXU.cwA.XXXXXX.XXXXXXXX-XXX”, “direction”: “out” } ], “disabled”: false } 我的function是: using System; using System.Net; using System.Net.Http; using Microsoft.Azure.WebJobs.Host; public class BotMessage { public string Source […]

Azure Functions .NET Core中的EF Core 2.0连接字符串

我使用.net核心在Azure Functions中使用EF core 2.0。 我正在尝试从local.settings.json读取db ConnectionString,其定义如下: { “IsEncrypted”: false, “Values”: { “AzureWebJobsStorage”: “UseDevelopmentStorage=true”, “AzureWebJobsDashboard”: “UseDevelopmentStorage=true” }, “ConnectionStrings”: { “MyDbConnStr”: “Data Source=.;Initial Catalog=xxxxxxx” } } Environment.GetEnvironmentVariable()不返回任何连接字符串信息,我也不能使用带有.net核心的ConfigurationManager.ConnectionStrings。 如何从代码中访问连接字符串?

Azurefunction绑定重定向

是否可以在azure函数文件夹结构中包含web.config或app.config文件以允许程序集绑定重定向?