当前位置: 首页 > 知识库问答 >
问题:

TimeTrigger异常“无法为ScheduleMonitor创建BlobContainerClient。

刘英彦
2023-03-14

当我使用TimeTrigger运行我的azure函数时,我遇到这个错误:Microsoft.Azure.WebJobs.Extensions.Timers.Storage:无法为SchrementMonitor创建BlobContainerClient。

我使用主机生成器:

public static async Task Main()
        {
            var host = CreateHostBuilder().Build();

            using (host)
            {
                await host.RunAsync();
            }

        static IHostBuilder CreateHostBuilder() => new HostBuilder()
            .UseServiceProviderFactory(new AutofacServiceProviderFactory())
            .ConfigureFunctionsWorkerDefaults()
            .ConfigureHostConfiguration(configHost =>
            {
                configHost.SetBasePath(Directory.GetCurrentDirectory());
                configHost.AddJsonFile("host.json", optional: true);
                configHost.AddEnvironmentVariables();
            })
            .ConfigureAppConfiguration((hostContext, configApp) =>
            {
                var env = hostContext.HostingEnvironment;
                configApp.AddJsonFile("appsettings.json", optional: true);
                configApp.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
                configApp.AddEnvironmentVariables();
                configApp.AddApplicationInsightsSettings(developerMode: !env.IsProduction());
            })
            .ConfigureServices((hostContext, services) =>
            {
               [...]
            })
            .ConfigureContainer<ContainerBuilder>(builder =>
            {
                builder.RegisterModule<MessagerModule>();
            })
            .ConfigureLogging((hostContext, configLogging) =>
            {
                if (hostContext.HostingEnvironment.IsDevelopment())
                {
                    configLogging.AddConsole();
                    configLogging.AddDebug();
                }
            })
            .UseConsoleLifetime();

这是函数:

[Function("QueueMessage")]
        public async Task QueueMessageAsync(
            [TimerTrigger("%MessageQueuerOccurence%", RunOnStartup = true)] TimerInfo timer
        )
        {
           [...]
        }

csproj:

<PropertyGroup>
        <TargetFramework>net6.0</TargetFramework>
        <AzureFunctionsVersion>v4</AzureFunctionsVersion>
        <OutputType>Exe</OutputType>
    </PropertyGroup>

    <ItemGroup>
        <Content Include="**\*.json" Exclude="bin\**\*;obj\**\*" CopyToOutputDirectory="Always" />
    </ItemGroup>
    
    <ItemGroup>
        <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
        <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.20.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.0.13" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.1.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="5.0.0" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.3.0" OutputItemType="Analyzer" />
        <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.6.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
        <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="6.0.0" />
    </ItemGroup>

local.settings.json

{ "IsEncrypted": false," Values ":{ " azurewebjobstorage ":" UseDevelopmentStorage = true "," MessageQueuerOccurence ":" 0 */15 * * * * "," FUNCTIONS _ WORKER _ RUNTIME ":" dot net-isolated " } }

我错过了什么?

注:Github链接:https://Github . com/Azure/Azure-functions-dot net-worker/issues/779

共有1个答案

张成济
2023-03-14

我遇到了这个问题,因为我没有运行存储模拟器...

一旦我安装并运行azurite,它就可以工作了,这是正在维护的存储模拟器(Azure存储资源管理器已停产)。您可以在此处找到有关如何安装和使用它的更多信息。

我在Mac OS上使用VS Code,我找到了在VS Code上安装azurite扩展的最简单解决方案。安装完成后,我只需要编辑扩展设置,以便设置位置设置(任何文件夹都应该有效)。之后,我能够通过运行Azurite:从VS Code命令面板开始来启动azourite

根据注释,可能还需要编辑local.settings.json文件并将AzureWebJobStorage值更改为UseDevelopmentStorage=true

 类似资料:
  • 当面对选择抛出异常的类型时,您可以使用由别人编写的异常 - Java平台提供了许多可以使用的异常类 - 或者您可以编写自己的异常类。 如果您对任何以下问题回答“是”,您应该编写自己的异常类;否则,你可以使用别人的。 你需要一个Java平台中没有表示的异常类型吗? 如果用户能够区分你的异常与由其他供应商编写的类抛出的异常吗? 你的代码是否抛出不止一个相关的异常? 如果您使用他人的例外,用户是否可以访

  • org.openqa.selenium.SessionNotCreatedException:无法创建新会话。(原始错误:命令失败:C:\Windows\system32\cmd.exe/s/C“C:\Program Files(x86)\Android\Android sdk\platform tools\adb.exe”-s 69c7aa170104安装“C:\Program Files(x8

  • 我的实际用户在Crashlytics上发布了这个异常数百次,我无法在5个不同的设备上复制一次 崩溃日志 需要注意的事项:1-绘图不是矢量绘图,它是一个带有透明背景的png(mdpi,hdpi,XHDPI.xxhdpi,xxxhdpi) 2-绘图是由Android Assets Studio创建的 3-这可能是这个问题的副本,我不太确定是否有解决方案 如何解决这个问题,或者有一个变通办法只是防止它发

  • 它的发生是因为我创建了许多线程,而没有关闭它们?还是经常创造新的? 有人能告诉我在代码中是否做错了什么吗?

  • 我想在Eclipse中用for创建10个txt文件,但是为什么我这么做的时候会出错?

  • 问题内容: 我正在编写一个可与​​google map及其上的许多标记一起使用的应用程序。我的任务是在Google地图上创建并显示一些标记。标记中包含自定义图像和文本。数据正在从服务器加载,每当用户移动Google Map Camera时,我就需要显示新的数据量。所以我正在使用android-maps- utils:0.4.3库来创建自定义位图(使用IconGenerator),然后从中创建Bit