Cuando ejecuto mi función azul con TimeTrigger, aparece este error: Microsoft.Azure.WebJobs.Extensions.Timers.Storage: no se pudo crear BlobContainerClient para ScheduleMonitor.
Yo uso un generador de host:
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();y aquí está la función:
[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": { "AzureWebJobsStorage": "UseDevelopmentStorage=true", "MessageQueuerOccurence": "0 */15 * * * *", "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated" } }
¿Qué me perdí?
nota: enlace a Github: https://github.com/Azure/azure-functions-dotnet-worker/issues/779
Estaba teniendo este problema porque no tenía el emulador de almacenamiento ejecutándose...
Funcionó una vez que instalé y ejecuté azurite , que es el emulador de almacenamiento que se mantiene (se suspendió Azure storage explorer ). Puede encontrar más información aquí sobre cómo instalarlo y usarlo.
Estoy usando VS Code en un sistema operativo Mac y encontré la solución más simple para instalar la extensión azurite en VS Code. Después de la instalación, solo tuve que editar la configuración de la extensión para establecer la configuración de location (cualquier carpeta debería funcionar). Después de eso, pude iniciar azurite ejecutando Azurite: Start from the VS Code command palette.