标签: azure-functions-runtime

了解 Azure Functions 行为

我正在尝试转向无服务器的东西,但我发现自己不明白如何移植我现有的后端代码。我需要澄清以下假设:

  1. Azure 函数是否被视为单线程代码?
  2. 在函数中使用 TPL 和 PLINQ 总是一个坏主意吗?
  3. static与常规应用服务相比,会员的开销是多少?基本上,我们对AppDomain寿命有任何保证吗?
  4. 如果我使用诸如NLoglog4net 之类的日志记录框架,其异步附加程序需要专用线程,我是否需要担心任何事情?
  5. 如何监控每个函数运行占用了多少内存?
  6. 是否可以设置一个 DI 容器,以便将我的依赖项注入到Run方法中?类似的东西:

    [FunctionName("ServiceBusQueueTriggerCSharp")]                    
    public async Task RunAsync(
       [ServiceBusTrigger("myqueue", AccessRights.Manage, Connection = "meconn")]
       string myQueueItem,
       IBusinessLogicService blService,
       ILogService logService,
       IMailingService mailService) {
    }
    
    Run Code Online (Sandbox Code Playgroud)
  7. 是否有可能获得CancellationTokeninRun方法以便我可以优雅地取消/关闭?

.net multithreading azure azure-functions azure-functions-runtime

2
推荐指数
1
解决办法
648
查看次数

Azure 函数:绑定类型“eventHubTrigger”未注册

我创建了一个 Azure 函数,使用 IoT 中心的 EventHub 的内置端点将消息从 Azure IoT 中心存储到表存储。我正在使用 Azure Functions v2(.Net Standard) 来创建 EventHubTrigger 函数。我开发了该函数并在本地对其进行了测试,它按要求工作。但是当我在 Azure 中托管此功能时,它在门户中显示以下错误:

错误:绑定类型“eventHubTrigger”未注册。请确保类型正确且已安装绑定扩展。

我已经在代码中安装了 Microsoft.Azure.WebJobs.Extensions.EventHubs -v 3.0.0-beta4 nuget 包。

有人可以帮助解决此错误,因为文档中对此没有提及太多。

以下是解决方案中安装的软件包:

  1. Microsoft.NET.Sdk.Functions 1.0.13
  2. Microsoft.Azure.WebJobs.EventHubs 3.0.0-beta4
  3. NETStandard.Library v2.0.3

azure azure-iot-hub azure-functions azure-functions-runtime

2
推荐指数
1
解决办法
4351
查看次数

如何在 VS 和 Azure 中同步 local.setting.json

我正在从 VS 开发 azure 函数。我不时部署到 Azure 并进行测试。我的应用程序在 local.settings.json 中有很多设置

每次我在一个地方更改时都必须在每个地方手动进行。有没有办法让它自动化或一个简单的方法?

谢谢

azure azure-functions azure-function-app-proxy azure-functions-runtime azure-functions-core-tools

1
推荐指数
1
解决办法
1087
查看次数

Azure Function:内存不足,无法继续执行程序

尝试在本地运行 Azure Functions 项目并收到以下错误:

Insufficient memory to continue the execution of the program.
Run Code Online (Sandbox Code Playgroud)

这发生在记录或启动任何内容之前,因此无需调试。

有人知道如何调试这个吗?

我已经删除了所有代码,删除了所有依赖项。剩下的只是一个没有实现的默认计时器函数。它仍然不起作用。

如果我创建一个新的函数项目 func init,一切正常。我看不到不起作用的项目和起作用的项目之间的项目文件、host.json、local.settings.json、function.json 等有任何差异。

我正在考虑重新实现该项目并复制所有代码,但这是唯一的解决方案吗?

azure-functions azure-functions-runtime

1
推荐指数
1
解决办法
1280
查看次数

1
推荐指数
2
解决办法
768
查看次数

C#中Azure功能的Application Insight Logging

我们在C#中具有服务总线触发的Azure函数。我想在Application Insight中记录信息(例如调用的函数,结果,异常)。我已将TraceWriter转换为Ilogger以获取登录信息。我要实现的是在控制台(本地)以及Application Insight实例上进行日志记录。什么是实现此目标的完美方法?

    public static class AIFunction
{
    private static string key = TelemetryConfiguration.Active.InstrumentationKey = "************************";

    private static TelemetryClient telemetryClient =
        new TelemetryClient() { InstrumentationKey = key };

    [FunctionName("AIFunction")]
    public static void Run([ServiceBusTrigger("AIFunctionQueue", AccessRights.Manage, Connection = "ServiceBus")]string queueItem, ILogger log)
    {
        telemetryClient.Context.Cloud.RoleName = "AIFunction";
        log.LogInformation($"C# ServiceBus queue trigger function processed message: {queueItem}");
        log.LogInformation($"C# ServiceBus queue trigger function to test Application Insight Logging");
        telemetryClient.TrackEvent("AIFunction TrackEvent");
        telemetryClient.TrackTrace("AIFunction TrackTrace");
    }
}
Run Code Online (Sandbox Code Playgroud)

c# azure azure-application-insights azure-functions azure-functions-runtime

0
推荐指数
1
解决办法
3960
查看次数

Azure Functions NodeJS Express 应用程序抛出无法确定函数入口点错误

我正在尝试使用nodejs 和express 创建一个简单的hello world azure 函数应用程序。但是,我收到以下错误:

Exception while executing function: Functions.httpexpressapp. mscorlib: Unable to determine function entry point. If multiple functions are exported, you must indicate the entry point, either by naming it 'run' or 'index', or by naming it explicitly via the 'entryPoint' metadata property.
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

函数.json

 {
  "bindings": [
    {
      "authLevel": "anonymous",
      "type": "httpTrigger",
      "direction": "in",
      "name": "req"
    },
    {
      "type": "http",
      "direction": "out",
      "name": "res"
    }
  ],
  "entryPoint": "index",
  "disabled": false
}
Run Code Online (Sandbox Code Playgroud)

索引.js:

const express = require('express') …
Run Code Online (Sandbox Code Playgroud)

azure node.js express azure-functions azure-functions-runtime

0
推荐指数
1
解决办法
1950
查看次数