3
votes

I am trying to configure Azure Storage Emulator 2.4 work with Local SQL server 2012.
When I execute this command, I get cannot create Database.

C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator>WAStorageEmulator.exe init -server ThisPC -sqlinstance SQLEXPRESS -forcecreate

Windows Azure Storage Emulator 3.3.0.0 command line tool
Error: Cannot create database.

To my Sql Sever Manager I login using server name ThisPC\SQLEXPRESS.
Please help me on which information i have missed.

----------------- Updated -----------------

C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator>WAStorageEmulator.exe init -server (local)\SQLExpress -forcecreate

Windows Azure Storage Emulator 3.3.0.0 command line tool Error: Cannot create database.

If you look at AppData\Local\WAStorageEmulator\WAStorageEmulator.3.3.config you'll find:

<SQLInstance>(local)\SQLExpress</SQLInstance>

Thanks to Gaurav on reminding me on logs, I checked my Event Viewer:

Cannot create file 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\WAStorageEmulatorDb33.mdf' because it already exists

It said the SQL DB files exists, so deleted it and retried the command, worked fine and storage emulator also started. (command worked second attempt after some time might be some SQL cache issue)

1
When you login through SSMS into your SQLExpress instance, can you login using Windows Authentication or do you use SQL Server authentication?Gaurav Mantri
Windows Authenticationharshal
Hmm...this is weird. I executed the command above and a bunch of other options and it worked fine for me. Can you please try: WAStorageEmulator.exe init -server (local)\SQLExpress -forcecreate and see if that works for you?Gaurav Mantri
I'm also using the same. Do you see any logs in AppData\Local\WAStorageEmulator\Logs folder or Event logs?Gaurav Mantri
logs folder is empty but i cheked my event viewer i see Cannot create file 'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\WAStorageEmulatorDb33.mdf' because it already exists. Change the file path or the file name, and retry the operation. deleted those files. Create DB worked. emulator started.harshal

1 Answers

7
votes

I would like to propose an answer based on the information from the OP's post/comments for readers from the future who get here after a some searching.

It is quite easy, and really the main piece of pertinent information is that you must first delete the existing database file located at:

C:\Users\\WAStorageEmulatorDb33.mdf

Then you can reinitialize the emulator. So run the Azure Storage Emulator and initialize it with your desired SQL instance:

WAStorageEmulator.exe init -server (local)\SQLExpress

Things that can go wrong:

  1. You may not be running the command prompt with elevated permissions. Usually Windows will prompt you if you wish to allow it to make changes, but it if doesn't and you get a failure message, run the tool with administrator permissions.
  2. Your server location/instance name may differ. The OPs is (local)\SQLExpress, mine was (localdb)\CompanyName. Make sure yours is correct.