函数监听器无法启动.Azure 函数应用时间触发器

Listener for function was unable to start. Azure function app timetrigger(函数监听器无法启动.Azure 函数应用时间触发器)

本文介绍了函数监听器无法启动.Azure 函数应用时间触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在本地环境中从 Visual Studio 运行 azure 函数时出现以下错误:

I'm getting the following error when I run the azure function from visual studio in local environment:

函数Function1"的侦听器无法启动.Microsoft.WindowsAzure.Storage:错误请求.

The listener for function 'Function1' was unable to start. Microsoft.WindowsAzure.Storage: Bad Request.

这是我的代码

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace FunctionApp3
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
        }
    }
}

配置(即local.settings.json)

and configuration (i.e, local.settings.json)

{
    "IsEncrypted": false,
    "Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=true",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
    }
}

但是当我设置一个 http 触发函数应用程序时,它工作正常.

But when I setup a http trigger function app, it works fine.

推荐答案

更新:

由于您使用的是本地虚拟化存储模拟器,因此您的连接字符串是正确的.

Since you use a locally virtualized Storage Emulator, then your Connecting String is correct.

如果您的防火墙限制 func 访问存储帐户,则可能会报告此错误.防火墙是监听器无法访问虚拟存储模拟器的原因之一.

If your firewall restricts func from accessing the Storage Account, then this error may be reported. The firewall is one of the reasons that the listener cannot access the virtual Storage Emulator.

在本地运行该函数时,除httptrigger外的所有触发器都需要使用存储模拟器.如果防火墙限制侦听器对虚拟存储的访问,则在执行功能时可能会出现问题.这就是使用 httptrigger 不会出错的原因,因为它不使用虚拟存储模拟器.

When running the function locally, all triggers except httptrigger need to use the Storage Emulator. If the firewall restricts the listener's access to virtual storage, problems can occur when performing functions. That's why you don't get errors with httptrigger, because it doesn't use a virtual Storage Emulator.

尝试禁用防火墙,看看是否能解决问题.

Try disabling the firewall and see if that resolves the issue.

当然也有可能是Storage Emulator服务没有打开.尝试输入

"%programfiles(x86)%Microsoft SDKsAzureStorage EmulatorAzureStorageEmulator.exe" status

在cmd中查看状态.

如果返回false,输入以下命令启动Storage Emulator:

If it returns false, enter the following command to start the Storage Emulator:

"%programfiles(x86)%Microsoft SDKsAzureStorage EmulatorAzureStorageEmulator.exe" init
"%programfiles(x86)%Microsoft SDKsAzureStorage EmulatorAzureStorageEmulator.exe" start

总结一下:

这类问题一般有三个原因.

This type of problem is generally for three reasons.

1.连接字符串错误阻止连接,

1.Connection string error prevents connection,

2.防火墙已设置

3.部分服务未开启.

希望对你有帮助.

原答案:

同样的代码在我这边也能正常工作,

Same code works fine on my side,

解决方案:

尝试将相同的代码复制到不同的位置.

Try to copying the same code to a different location.

也许这个可以帮助你.

这篇关于函数监听器无法启动.Azure 函数应用时间触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:函数监听器无法启动.Azure 函数应用时间触发器

基础教程推荐