标签: azure-functions

Azure 事件网格 / 函数 / ngrok

我正在尝试按照使用 ngrok 进行本地测试的说明进行操作

我使用 C# 示例在本地运行我的事件网格和我的函数在 VS 中运行。但是,当我尝试使用端点订阅我的事件时

https://xxxx.ngrok.io/admin/extensions/EventGridExtensionConfig?functionName=EventGridTrigger
Run Code Online (Sandbox Code Playgroud)

我的本地 ngrok 控制台显示:

POST /admin/extensions/EventGridExtensionConfig 404 Not Found
Run Code Online (Sandbox Code Playgroud)

VS中的函数代码:

  [FunctionName("EventGridTrigger")]
    public static void Run([EventGridTrigger]EventGridEvent eventGridEvent, TraceWriter log)
    {
        log.Info(eventGridEvent.Data.ToString());
    }
Run Code Online (Sandbox Code Playgroud)

azure azure-functions azure-eventgrid

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

是否可以使用 Azure Functions V2 输出 Message/BrokeredMessage?

文档中不清楚如何输出结构化消息。在我使用过的旧函数中BrokeredMessage,文档说要Message用于 V2 函数,但是没有关于如何使用它的指导。这样对吗:

[FunctionName(nameof(Job))]
public static async Task<IActionResult> Job(
    // ...
    IAsyncCollector<Microsoft.Azure.ServiceBus.Message> serializedJobCollector
)
Run Code Online (Sandbox Code Playgroud)

目标是能够设置一些元数据属性,如 ID,我之前(使用 V1 和BrokeredMessage)做过重复检测,但我不确定这是否正确,或者我需要序列化为字符串或什么...

c# azure azureservicebus azure-functions

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

编译 Azure Function v1 (.NET Framework) 为 Microsoft.Azure.WebJobs 提供 FileNotFoundException

我在 Visual Studio 2017 中有一个 Azure Functions v1 项目(ala .NET Framework)。它可以很好地构建/编译很长时间,现在它给出以下 FileNotFoundException 抱怨它找不到“Microsoft.Azure.WebJobs”v2 .2. 这个项目构建得很好,然后突然发生了这个错误。

过去我会关闭 Visual Studio,然后重新打开它,构建就可以工作了。或者,即使您清理了解决方案,构建也将起作用。问题是现在无论我做什么我都会收到这个错误。我什至重新启动了计算机!

这是 Visual Studio 2017 中针对 Azure Functions v1 项目显示的完整编译器异常:

Severity    Code    Description Project File    Line    Suppression State
Error       System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Azure.WebJobs, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Azure.WebJobs, Version=2.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
   at System.ModuleHandle.ResolveType(RuntimeModule module, Int32 typeToken, IntPtr* typeInstArgs, Int32 typeInstCount, IntPtr* methodInstArgs, Int32 methodInstCount, ObjectHandleOnStack type) …
Run Code Online (Sandbox Code Playgroud)

.net azure visual-studio azure-functions visual-studio-2017

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

持久功能:从“UsePollingFileWatcher”获取值时出错

这个错误刚刚开始突然发生。我在 Azure 中有一个持久函数,它已经运行了大约 6 周没有问题,上周开始失败。

Error getting value from 'UsePollingFileWatcher' on 'Microsoft.Extensions.FileProviders.PhysicalFileProvider'.
Run Code Online (Sandbox Code Playgroud)

我在本地尝试过并得到相同的错误。在工作和现在不工作之间绝对没有代码更改。我真的很难过。

Newtonsoft.Json.JsonSerializationException
HResult=0x80131500
Message=Error getting value from 'UsePollingFileWatcher' on 'Microsoft.Extensions.FileProviders.PhysicalFileProvider'.
Source=Newtonsoft.Json
StackTrace:
at Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(Object target)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)
at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty …
Run Code Online (Sandbox Code Playgroud)

azure-webjobs asp.net-core azure-functions azure-durable-functions

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

如何将 function.json 添加到现有的 .NET function 2.0

当我使用此函数中func new --name MyHttpTrigger --template "HttpTrigger"没有function.json创建的方法添加新函数时,当我尝试将其添加到当前目录并运行时func start --build,出现此错误:

没有找到工作职能。尝试公开您的作业类和方法。如果您使用绑定扩展(例如 Azure Storage、ServiceBus、Timers 等),请确保您已在启动代码(例如 builder.AddAzureStorage()、builder.AddServiceBus() 中调用了扩展的注册方法)、builder.AddTimers() 等)。

你可以在这里找到我的function.json内容:

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

之前的 httpTrigger 函数

namespace final
{
    public static class httpTrigger
    {
        [FunctionName("httpTrigger")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-functions serverless

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

为什么 GenerateFunctions 无法查找 System.Runtime, Version=4.2.1.0 并抛出 FileNotFoundException)?

我使用最新的 1.0.26 Microsoft.Net.Sdk.FunctionsNuGet 包将 Azure Function v2 创建为 DotNet Core 库 (2.1) 。

我无法构建 Azure Functions,因为该GenerateFunctions任务正在寻找System.Runtime. 但是,没有该特定版本的 NuGet 包。

谁在寻找 System.Runtime 4.2.1.0,我该如何解决?

这是构建失败的诊断日志部分:

2>Target "_GenerateFunctionsPostBuild" in file "C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\Microsoft.NET.Sdk.Functions.Build.targets":
2>  Using "Move" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
2>  Task "Move"
2>    Task Parameter:SourceFiles=C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\NoSuchCompany.Demo.Service.AzureFunctions.pdb
2>    Task Parameter:DestinationFiles=C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\bin\NoSuchCompany.Demo.Service.AzureFunctions.pdb
2>    Task Parameter:OverwriteReadOnlyFiles=True
2>    Moving file from "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\NoSuchCompany.Demo.Service.AzureFunctions.pdb" to "C:\NoSuchCompany\Service\src\bin\Debug\netcoreapp2.1\bin\NoSuchCompany.Demo.Service.AzureFunctions.pdb".
2>  Done executing task "Move".
2>  Using "GenerateFunctions" task from assembly "C:\Users\Chris\.nuget\packages\microsoft.net.sdk.functions\1.0.26\build\netstandard1.0\..\..\tools\net46\\Microsoft.NET.Sdk.Functions.MSBuild.dll".
2>  Task "GenerateFunctions"
2>    Task …
Run Code Online (Sandbox Code Playgroud)

c# msbuild azure azure-functions

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

如何在 Azure 函数消费计划中打开 Kudu 控制台?

我正在制定 Azure Functions 消费计划,并尝试按照此 stackoverflow 答案中的指南进行操作:https : //stackoverflow.com/a/43984890/6700475

如何执行第 2 步,即“打开 Kudu 控制台”?我试过了:

  • 单击门户中的“高级工具 (Kudu)” - 但收到此警告:“Linux 消费函数是预览版。”
  • 使用:https : //MYFUNCTION.scm.azurewebsites.net/查找 SCM 页面,但此页面不可用。

还有另一种打开 Kudu 控制台的方法,它适用于 Azure 功能的消费计划吗?

(我需要这个的原因是我有一个需要部署到 Azure 函数的 Python 函数,但它在 python 工作器中因这个问题而失败,而且我没有 Docker:https : //github.com/Azure/azure -functions-python-worker/issues/367 )

azure kudu azure-functions

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

带有 CosmosDb 绑定的 Azure 函数正确的本地设置

我确定我在这里遗漏了一些简单的东西,但我无法让它发挥作用。我在本地安装了 Azure 存储模拟器,并通过 Visual Studio 2019 创建了 Azure Function 2.0。

我可以在没有 CosmosDb 绑定的情况下运行该函数,如下所示:

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "EndpointUri": "https://localhost:8081",
    "PrimaryKey": "<KEY_HERE>"
  }
}
Run Code Online (Sandbox Code Playgroud)

Function.cs

public static class Function
{
    [FunctionName("func")]
    public static async Task Run(
        [TimerTrigger("0 * * * * *")] TimerInfo myTimer,
        ILogger log
    )
    {
        log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

        var endpointUri = new Uri(Environment.GetEnvironmentVariable("EndpointUri", EnvironmentVariableTarget.Process));
        var primaryKey = Environment.GetEnvironmentVariable("PrimaryKey");

        using (var client = new DocumentClient(endpointUri, primaryKey))
        {
            var queryOptions …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-functions azure-cosmosdb

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

永远不会执行的 Azure 函数作业

我正在尝试填充一个 CRON 表达式,该表达式将假装永远不会执行(至少在此生期间不会)。

我经历了这个问题 /sf/ask/582701451/

但是该问题中的每个表达式都给出了一个例外 Microsoft.Azure.WebJobs.Host: Error indexing method 'Cleanup'. Microsoft.Azure.WebJobs.Extensions: The schedule expression '0 0 5 31 2 ?' was not recognized as a valid cron expression or timespan string.

有哪些可能的表达方式可以满足上述对 Azure Functions 的期望?

谢谢你。

cron azure azure-functions

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

Azure 函数无法连接到 Azure SQL 数据库

我创建了一个应该连接到 Azure SQL 数据库的 Azure 函数。

此函数检索保存在应用程序配置中的连接字符串。此连接字符串是 Azure SQL 提供的连接字符串。

在我的 PC 上一切正常,但我已在 Azure 上部署了该功能,但它似乎无法连接到 SQL 数据库(返回常见错误“未设置对象引用...”)。

我已签possibleOutboundIpAddresses入 Azure 函数资源,并已在 Azure SQL 防火墙上允许它们。

此外,我的 SQL 数据库位于带有存储的 Azure VNet 中。

任何的想法?

azure azure-sql-database azure-functions

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