23

When I run my azure function with TimeTrigger I have this error:

Microsoft.Azure.WebJobs.Extensions.Timers.Storage: Could not create BlobContainerClient for ScheduleMonitor.

I use a host builder:

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(); 

and here is the function:

[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" } } 

What did I miss?

Note: link to GitHub: https://github.com/Azure/azure-functions-dotnet-worker/issues/779

2
  • 1
    Are you getting this error locally or after deployment in Azure? Commented Jan 19, 2022 at 3:44
  • 1
    Hi, I have this error locally. Commented Jan 19, 2022 at 15:11

7 Answers 7

42

I was having this issue because I didn't have the storage emulator running...

It worked once I installed and ran azurite, which is the storage emulator that is being maintained (Azure Storage Emulator has been discontinued). You can find more information here on how to install it and use it.

I am using VS Code on a Mac OS, and I found the simplest solution to install azurite extension on VS Code. After the installation, I just had to edit the extension settings, in order to set the location setting (any folder should work). After that I was able to start azurite by running the Azurite: Start from the VS Code command palette.


As per the comments, it might also be necessary to edit the local.settings.json file and change the AzureWebJobsStorage value to UseDevelopmentStorage=true.

Sign up to request clarification or add additional context in comments.

5 Comments

Thanks for your suggestion :) The storage emulator is already running, what I found is when I delete the appsettings.json and appsettings.Development.json, the issue disapears. I added this comment to github, as it's a preview version, maybe there is something not well configured ...
avec plaisir! I am not using any of those files on my setup, btw
On top of that, I also had to edit the local.settings.json file and change the AzureWebJobsStorage value to UseDevelopmentStorage=true. HTH :)
thanks for posting this, but why do we even need this? What does blob storage have to do with a timer function??
@d512 every function app requires a storage account to operate.
21

I'm using .net7 (Azure.Functions.Worker)

Inside your local.settings.json file make sure to specify the key 'AzureWebJobsStorage'

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

3 Comments

In my case, I had nested objects inside the local.settings.json, and so the AzureWebJobsStorage was not being recognized correctly. Fixing that solved the issue
In my case, I need to use "FUNCTIONS_WORKER_RUNTIME": "dotnet"
This solved it for me, my setting was empty: "AzureWebJobsStorage": ""
3

I'm not 100% certain but I think this issue started for me once I updated visual studio. So I've been trying to sort this out for 2 days. I tried many different things:

  • Installed latest windows update
  • Delete previous versions of Visual Studio i.e. 2019
  • Updated Visual Studio 2022
  • Deleted Visual Studio 2022
  • Installed Visual Studio 2022 Preview
  • Reinstalled Azurite extension in VS Code and set location to ..AppData/Temp
  • Deleted and re-cloned my repo.
  • Cleaned and rebuilt code.
  • Deleted the azurite db files
  • Deleted the whole azure folder in AppData/Temp
  • Manually ran Azurite in powershell
  • Ran Azurite in VS Code
  • Reinstalled Azurite extension in VS Code

Nothing seemed to work. I then realised that I forgot to do the obvious...

DELETE THE OBJ AND BIN FOLDERS

After doing that it worked.

Now what doesn't make sense is that after re-cloning the repo it is basically deleting the bin and obj folders.

So I don't think that's the only reason why things worked.

Prior to deleting the obj and bin folders I also tried:

  • making sure all services listening on ports 10000, 10001, 10002 were stopped.

  • ran Azurite in Powershell from C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator

  • Opened Azure Storage Explorer and created dummy container called 'test'

  • Used the actual connection string (DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=https://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=https://127.0.0.1:10001/devstoreaccount1;TableEndpoint=https://127.0.0.1:10002/devstoreaccount1;) for the Azurite emulator instance in the local.settings.json file instead of UseDevelopmentStorage=true

2 Comments

Thanks for this, I had the same exact issue - local.settings.json was correct, local Azurite was running, just needed to delete bin and obj directories.
For me doing a rebuild in Visual Studio did it, which also pointed out code errors not previously marked.
1

I ran into this issue because my local.settings.json file was faulty. I was missing a comma at the end of one of my properties inside the Values object. Bit of a misleading error message in my case.

1 Comment

Same here. Seems I had nested properties in my config, which does not seem to work in FA
0

In my case the FunctionName [FunctionName("Email")] was not the same as the classname Nip.cs in the root.

When changing the FunctionName to Nip it all worked again.

Comments

0

For what it is worth, I think it is important to mention, the issue can happen if your local.settings.json is set as 'DoNotCopy'.

Ensure the following is in your project file:

<ItemGroup>   <None Update="local.settings.json">     <CopyToOutputDirectory>Always</CopyToOutputDirectory>   </None> </ItemGroup> 

Comments

-1

I made added new file named: local.settings.json, and added in these configurations (see image). Adding these configurations in appsettings.Development.json did not work.

enter image description here

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.