54

In testing Azure Functions locally, I am receiving this error:

"There was an error performing a read operation on the Blob Storage Secret Repository. Please ensure the 'AzureWebJobsStorage' connection string is valid."

I have Azure Blob Storage setup, including Storage Emulator and Storage Explorer. How can this be fixed?

mattsmith5
  • 540
  • 4
  • 29
  • 67

8 Answers8

174

I had this issue with Azure Durable Functions, I found the way to resolve it here: https://github.com/Azure/azure-functions-host/issues/3795#issuecomment-430337085

In local.settings.json, add a new setting called AzureWebJobsSecretStorageType and set it to "files".

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "AzureWebJobsSecretStorageType": "files"
  }
}
Martin Wickman
  • 19,662
  • 12
  • 82
  • 106
Juliana Polo
  • 1,911
  • 1
  • 8
  • 5
  • 4
    Great answer! Maybe the push to replace Azure Storage Emulator on Windows has been a little hasty – Rob Bowman Jan 19 '22 at 16:46
  • 12
    After ~2+ years this just bit me. `"AzureWebJobsSecretStorageType": "files"` appears to have automagically been required. – Aaron Hudon Feb 05 '22 at 00:12
  • 1
    As per Aaron Hudson, adding "AzureWebJobsSecretStorageType": "files" fixed my previously working local store debug setup. I had just introduced a timer trigger function, so maybe that changed runtime behaviour. Be careful about copying the "FUNCTIONS_WORKER_RUNTIME" setting above if targeting isolated functions. – camelCase Jul 31 '23 at 09:13
22

My Two cents.

I am trying to run a durable function on my local computer.

I was getting this error.

There was an error performing a read operation on the Blob Storage Secret Repository. Please ensure the 'AzureWebJobsStorage' connection string is valid

I looked at this answer from the github issue.

I completely deleted my folder the path for which is as follows

C:\Users\YourUserName\AppData\Local\Temp\Azurite 

Now things are running fine again.

The folder looks like this.

Azurite folder on Windows

Note: User noted it worked but had to delete my entire Temp folder - deleting the Azurite folder was not enough to resolve the issue

mattsmith5
  • 540
  • 4
  • 29
  • 67
VivekDev
  • 20,868
  • 27
  • 132
  • 202
  • 1
    This worked for me but I had to delete my entire Temp folder - deleting the Azurite folder was not enough to resolve the issue. – julianH Jun 28 '22 at 16:45
11

Please do not change the "AzureWebJobsStorage" parameter to your live storage account, as additional costs can occur and you maybe have unforeseen side effects or impact on you online environment. The storage emulator is long deprecated, you should use azurite to emulate storage locally. You can download azurite for example with npm (npm install -g azurite) or in many other ways.

"UseDevelopmentStorage=true" is exactly the correct setting to use in a local environment, especially when you are going to use durable functions or other compute or I/O heavy tasks. Regarding you problem, azurite creates multiple json files in the folder where you execute it for its virtual storage backend. If you run azurite without any parameters, the following files should be existent:

  • __azurite_db_blob_extent__.json
  • __azurite_db_queue__.json
  • __azurite_db_queue_extent__.json
  • __azurite_db_table__.json

In addition there are normally two or more folders called similar to this:

  • __blobstorage__
  • __queuestorage__

To force the azure-functions-core-tools runtime to reset storage claims and handles, first stop azurite and all func instances, delete the above files and folders and start it again (azurite first).

All the content will of course be gone, but local development storage should never be used for persistent data.

itpropro
  • 160
  • 1
  • 7
  • 1
    If Azurite was auto-started by Visual Studio, you can find the file location by going to the Output window, selecting "Service Dependencies", and finding the line near the top of scrollback where it starts Azurite. The location of the above files is passed as --location. – Martin Wilkerson Sep 24 '22 at 22:04
5

None of the other answers worked for me so I'll share my solution here. I tried:

  • Changing AzureWebJobsSecretStorageType
  • Killing the azurite process and restarting it
  • Removing all the files from AppData

None of that worked. The fix for me was to install azurite using npm install -g azurite and then run it with azurite. After that my old project started working again.

Andrei Dvoynos
  • 1,126
  • 1
  • 10
  • 32
4

This solution worked for me -

Run cmd as admin.

run command netstat -ano | findstr :10000 and coppy the PID of first IP address. In my case it was 18220.

Then run taskkill /PID 18220 /F

After that run "%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" init to re initilize the Azure Storage Emulator.

And finally run "%programfiles(x86)%\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" start to start the Azure Storage Emulator.

1

For anybody else who continues to get blob read errors after setting "AzureWebJobsSecretStorageType": "Files", downgrading the Microsoft.Azure.WebJobs.Extensions.Storage package from v5 to v4 can fix it. (I used v4.0.5).

This may be specific to .NET projects. If you are new to modifying c# dependencies, in your .csproj file find the PackageReference object and change the version. You can then run dotnet restore to update/refresh.

For those that don't like reading text:

project-name.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
      ...
  </PropertyGroup>
  <ItemGroup>
    ...
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.5"/>
    ...
  </ItemGroup>
  ...
</Project>

For the sake of SEO, this was my error:

System.InvalidOperationException: Secret initialization from Blob storage failed due to missing both an Azure Storage connection string and a SAS connection uri. For Blob Storage, please provide at least one of these. If you intend to use files for secrets, add an App Setting key 'AzureWebJobsSecretStorageType' with value 'Files'.
exax
  • 17
  • 1
  • 4
1

If you are using Visual Studio 2019 or later, you need to be sure "Azurite" services running.
How to be sure? -restart the VS and check output window VS Output window

If you are using VS Code or Rider you should run Azurite manually.

malisasmaz
  • 99
  • 1
  • 7
1

Struggled with this for a day or so, turns out I just needed to install a NuGet package

Microsoft.Azure.WebJobs.Extensions.Storage

andyb952
  • 1,931
  • 11
  • 25