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

☆樱花仙子☆ 提交于 2021-02-17 21:09:49

问题


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..


回答1:


  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.



回答2:


I was running into this same issue after installing LocalDb for SQL Server 2017. These steps helped me to resolve the problem I was facing:

  • Open a command line in C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator
  • Run AzureStorageEmulator.exe init /forceCreate
  • From checking my error logs (located at %USERPROFILE%\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\MSSQLLocalDB), I saw

2018-12-21 15:41:13.47 spid65 CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file 'C:\Users{username}AzureStorageEmulatorDb59.mdf'.

  • This error lead me to the following post: https://dba.stackexchange.com/questions/191393/localdb-v14-creates-wrong-path-for-mdf-files
  • From reading answers there, I gathered that this is a bug in SQL Server 2017. Without having access to the patch, the solution that worked for me was granting Everyone access to modify C:\Users. This was only an issue on my development laptop, so I could afford to make that security change
  • or as commented by Andrii install CU13 HotFix for SQL Server 2017. After that AzureStorageEmulatorDb<xxx>.mdf will be created you your user directory as it should.



回答3:


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.




回答4:


I had this problem and I don't know why an AzureStorageEmulatorDb57_log.ldf was still present in my %USERPROFILE% directory when I deleted my MSSQLLocalDB instance, but after dropping that file the problem went away.




回答5:


I came across this issue where I had changed the userlogin to my machine. I have created the database from my previous useraccount. I have copied the database files to the new user account but it gave me this error. It seems to be a permission issue.

You need to find the saved location of the mdf and ldf file of this database. In my case it was stored in 'C:\Users\yourUserName'

Simply delete these files and run AzureStorageEmulator.exe init again and it will create the new mdf and ldf files for you.




回答6:


After manually upgrading my MSSQL 2016 LocalDB to MSSQL 2019 following these instructions, I got the error mentioned as I was unaware that the Azure Storage Emulator uses LocalDB internally.

To fix it, I simply had to manually re-attach the database located in %UserProfile% with the following SQL command:

CREATE DATABASE [AzureStorageEmulatorDb510]
    ON (FILENAME = 'C:\Users\<username>\AzureStorageEmulatorDb510.mdf'),   
    (FILENAME = 'C:\Users\<username>\AzureStorageEmulatorDb510_log.ldf')   
    FOR ATTACH;



回答7:


Check you had install Azure SDK with Visual Studio, if you did't you can add the feature




回答8:


You can locate the mdf and ldf files in your userprofile directory. Just stop the emulator and copy those files to some other place and delete it from userprofile directory. Then run the emulator again and it's going to create new mdf and ldf files. Then stop the emulator and copy the old files back and restart the emulator. This way you won't loose any data.




回答9:


I will help you with this. First of all create a sql server local db. Then go to storage emulator folder _-The Storage Emulator is installed by default to C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator.

Then run this AzureStorageEmulator.exe init /server

docs: AzureStorageEmulator.exe init /server localhost\SQLEXPRESS01




回答10:


Worked for me:

  1. Delete any storage/sql database related to azure emulator
  2. run this command on StorageEmulator path:

AzureStorageEmulator.exe init /server .

(Or your SQL instance, Mine was ".")




回答11:


Open SSMS and connect to your (localdb) instance. Manually create the "AzureStorageEmulatorDb...".




回答12:


I initialized the db instance and succeed, bu my SQLServer is 2017.

Then I search the solution and the doc said delete the trouble database will solve the problem. Maybe you can try it follow the steps in the doc.

If you still have questions, please let me know.




回答13:


This solution is not recommended in generally, but you can try it. I think AzureStorageEmulator by somehow can not full access the localDB whitch setup in directory has limited the permission.

  1. You can go to folder propertiy > sercurity > edit to full permission ( with me directory is user > Appdata).
  2. Then restart the emulator cmd restart the azure emulator.

Now it worked. You must consider it's unsercurity later on.



来源:https://stackoverflow.com/questions/53673763/azure-storage-emulator-fails-to-init-with-the-database-azurestorageemulatordb5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!