Reputation: 970
While running a simple Timer Trigger Azure Function locally, I'm getting below error.
I create new Azure Functions project with timer trigger using Visual Studio 2019.
I have Azure development Workload installed.
Code:
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/12 * * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
Error:
[2021-11-24T15:45:29.878Z] The listener for function 'Function1' was unable to start.
[2021-11-24T15:45:29.880Z] The listener for function 'Function1' was unable to start. Azure.Storage.Blobs: Server encountered an internal error. Please try again after some time.
RequestId:3bb00ada-83ec-4685-987b-5d4b51cb39db
Time:2021-11-24T15:45:29.5583585Z
[2021-11-24T15:45:29.880Z] Status: 500 (Server encountered an internal error. Please try again after some time.)
[2021-11-24T15:45:29.881Z] ErrorCode: InternalError
This answer suggests to disable the firewall. It seems firewall is the issue for me also. When disabling firewall is not an option, is there any way to overcome this?
Upvotes: 4
Views: 11813
Reputation: 874
Recently, I also encountered the error in Visual Studio 2022.
The solution:
Download and install the Microsoft Azure Storage Explorer. On the download page select your operating system from the drop-down menu.
With Visual Studio open, and with the Azure Function project set as Startup Project, Open the Azure Storage Explorer by typing its name in the Windows start menu.
In the left menu, expand Storage Accounts -> (Emulator - Default Ports) (key) -> Blob Containers. Then left-click on azure-webjobs-hosts and select Delete.
Restart Visual Studio. Everything should work now.
References:
Cameron Dwyer blog
Issue on github
Upvotes: 4
Reputation:
After all the discussions, glad that your issue got resolved.
Here is my solution to help the other community members as tested in my local environment:
Below is the code:
local.settings.json
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
Function1.cs
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
namespace KrishTimerTriggerNetCore31
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("*/12 * * * *")]TimerInfo myTimer, ILogger log)
{
log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
Output:
When you created the azure functions project in Visual Studio with timer trigger template, by default your local.settings.json
file contains this value "AzureWebJobsStorage": "UseDevelopmentStorage=true"
If the UseDevelopmentStorage
to none
, then the same error will occurs:
Make Sure all required applications are installed and up to date for your requirement like Azure Functions Core Tools Version, Azure Storage emulator (locally), .Net Core Runtime Versions and SDKs and the extensions while installing Visual Studio.
Upvotes: 7