I'm getting the following error when I run the azure function from visual studio in local environment:
The listener for function 'Function1' was unable to start. Microsoft.WindowsAzure.Storage: Bad Request.
Here is my code
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}");
}
}
}
and configuration (ie, local.settings.json)
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
But when I setup a http trigger function app, it works fine.
Update:
Since you use a locally virtualized Storage Emulator, then your Connecting String is correct.
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.
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.
Of course, it is also possible that the Storage Emulator service is not open. Try typing
"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" status
in cmd to check the status.
If it returns false, enter the following command to start the Storage Emulator:
"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" init
"%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" start
To sum up:
This type of problem is generally for three reasons.
1.Connection string error prevents connection,
2.firewall is set
3.some services are not turned on.
Hope it helps.
Original Answer:
Same code works fine on my side,
Solution:
Try to copying the same code to a different location.
Maybe this can help you.
I found out that the problem lied in the fact I had the Azure Storage Emulator running in an other drive then I had my project. ie emulator was running on C:\\Emulator and project was running locally on S:\\MyFunction
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.