2

I have a similar issue as here, but this is running Azurite on windows with VS against an Azure Function.

I am trying to follow this documentation

Azurite is being initiated by VS through this setting in local.settings.json in the Azure Functions project:

"AzureWebJobsStorage": "UseDevelopmentStorage=true"

I have set the environment variables (also tried without quotation marks):

cmdscreenshot

My connection string is like this:

"DefaultEndpointsProtocol=http;AccountName=imageaccount;AccountKey=SU1BR0VfQkxPQl9TVE9SQUdFX1VSTA==;BlobEndpoint=http://127.0.0.1:10000/imageaccount;"

My BlobContainerClient seems set up to go: enter image description here

but calling

 await containerClient.CreateIfNotExistsAsync();

throws an exception telling me it is an "Invalid storage account"?

Further info:

  • per 26/06 - 2023
  • Latest version of VS 17.6.4
  • Azurite version installed by VS: 3.22.0 (Latest version is 3.24.0 ?)

Disabling Azurite startup in VS and running azurite from the console produces another exception with this message:

"The API version 2022-11-02 is not supported by Azurite. Please upgrade Azurite to latest version and retry. If you are using Azurite in Visual Studio, please check you have installed latest Visual Studio patch. Azurite command line parameter "--skipApiVersionCheck" or Visual Studio Code configuration "Skip Api Version Check" can skip this error. "

Running from console with the proposed --skipApiVersionCheck I am back to the original exception.

Setting up without the AZURITE_ACCOUNTS environment setting, and with "UseDevelopmentStorage=true" as connection string works

Any clues? Thx..

noontz
  • 1,782
  • 20
  • 29
  • What is the Azure Function Version you are using? – Harshitha Jun 26 '23 at 11:59
  • @Harshitha : Azure Functions Core Tools v. 4.0.4895 (x64) – noontz Jun 26 '23 at 12:02
  • Are you following the complete document or only `Custom storage accounts and keys` part ? – Harshitha Jun 26 '23 at 12:03
  • 1
    @Harshitha The entire documentation, but the essential part is the one you mention – noontz Jun 26 '23 at 12:05
  • I have tried to retrieve the `AZURITE_ACCOUNTS` value, but getting null.[Image](https://i.stack.imgur.com/9td99.png) – Harshitha Jun 26 '23 at 12:52
  • Once I close and reopen the commandprompt, Tried to run `SET` the value is not available. – Harshitha Jun 26 '23 at 12:55
  • Try to set the value in Properties=> Debug =>General.[Image](https://i.stack.imgur.com/twdMU.png) – Harshitha Jun 26 '23 at 12:57
  • @Harshitha Thx for the effort. Unfortunately adding the entry through launchSettings environmentVariables did not change anything. Pls. note that I have raised an issue on github if you have further inputs. https://github.com/Azure/Azurite/issues/2018 – noontz Jun 26 '23 at 13:29
  • Have you tried by setting the environment variable from properties section. – Harshitha Jun 26 '23 at 13:30
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/254249/discussion-between-noontz-and-harshitha). – noontz Jun 26 '23 at 13:31

1 Answers1

0

A workaround was found in this github issue

Currently there is flaws in the documentation and it lacks important details, so to make this work in the questions context, here is the way to go:

  • remove this entry "AzureWebJobsStorage": "UseDevelopmentStorage=true" from local.settings.json in ALL projects to prevent Azurite from starting up in the VS process
  • restart VS if Azurite is running (check Output > Service Dependencies)
  • start a separate command prompt as Administrator
  • navigate to the folder containing Azurite as per the documentation
  • run set AZURITE_ACCOUNTS=account1:key1;account2:key2 without quotation marks
  • run azurite --skipApiVersionCheck

Here is a .bat script for convenience (run as administrator):

cd C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\Azure Storage Emulator
set AZURITE_ACCOUNTS=set AZURITE_ACCOUNTS=account1:key1;account2:key2
azurite --skipApiVersionCheck

An alternative more "permanent" solution (keep the "AzureWebJobsStorage": "UseDevelopmentStorage=true" to start Azurite from VS) is adding the environment variable manually to the windows system variables e.g.

(for what ever reason, the setting must be set in the first startup project when using multiple startup projects in a solution)

enter image description here

noontz
  • 1,782
  • 20
  • 29