Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Storage Emulator fails to init with "The database 'AzureStorageEmulatorDb57' does not exist"

I am having an issue with Azure Storage Emulator. I tried to re-initialise the database and got the error below.

This was after installing Visual Studio 2019 Preview but this may just be a co-incidence. I tried for an hour or so to get it running and then gave up and just reset my machine with the "keep my files" option, re-installed Visual Studio 2017 and the Azure Tools but still see the same problem.

I know a reset sounds a bit drastic but VS 2019 broke my Azure Functions in VS2017, they would not launch so I wanted a clean install.

If I manually create the DB with sqllocaldb create (version 13.1.4001.0), the DB gets created fine but the init still fails with the same message.

Any ideas?

C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator>AzureStorageEmulator.exe init Windows Azure Storage Emulator 5.7.0.0 command line tool Found SQL Instance (localdb)\MSSQLLocalDB. Creating database AzureStorageEmulatorDb57 on SQL instance '(localdb)\MSSQLLocalDB'. Cannot create database 'AzureStorageEmulatorDb57' : The database 'AzureStorageEmulatorDb57' does not exist. Supply a valid database name. To see available databases, use sys.databases.. One or more initialization actions have failed. Resolve these errors before attempting to run the storage emulator again. Error: Cannot create database 'AzureStorageEmulatorDb57' : The database 'AzureStorageEmulatorDb57' does not exist. Supply a valid database name. To see available databases, use sys.databases..

like image 291
Murray Foxcroft Avatar asked Dec 07 '18 16:12

Murray Foxcroft


2 Answers

After resetting my machine (and keeping files), I ran into this issue. For me, I was unable to run an Azure function in Visual Studio 2019 due to an error around being unable to start the emulator.

It looks like I had the same permissions issues as (I presume) my new account after reset, did not have permission to touch the DB.

I resolved this by:

  1. Deleting the Azure Storage Emulator DB file: %USERPROFILE%/AzureStorageEmulatorDb[number].mdf
  2. Then running AzureStorageEmulator.exe start with admin rights

I was then able to run the Azure Function without issue.

like image 50
Ste Pammenter Avatar answered Sep 28 '22 04:09

Ste Pammenter


  1. Stop the Azure Emulator if it is running.
  2. Open SSMS and connect to your (localdb) instance.
  3. Manually create the "AzureStorageEmulatorDb57".
  4. Open a command prompt as Administrator.
  5. Run the "AzureStorageEmulator.exe init".
  6. Run your VS project.
like image 25
Bill Avatar answered Sep 28 '22 06:09

Bill