From out of nowhere I was hit with an Azure Storage Emulator 4.2 issue.
The Azure storage emulator wouldn't start and asked me to call AzureStorageEmulator.exe init.
After following the advise to call init, I then received the following error: "Cannot Create Database".
Unforunately the reason for this issue is not displayed so after trying a few potential solutions I found online, I ended up with the following which worked straight away.
The Azure Storage Emulator by default uses a local db instance.
I had no idea which instances I may have installed over the last year so I ran the following on the command line:
This command prints out the names of the localDB instances.
In my case I had the following installed:
Whilst I knew about v11.0, I had no idea there was another instance called MSSQLLocalDB installed.
In my case this was the culprit - some how the db files for the Azure Storage emulator had gone missing but were still registered in the instance. It now made sense why I couldn't create the database, the instance believed the database already existed.
Now that I had found the culprit and I knew I wasn't using the instance for anything else I used the command line to stop and delete it.
sqllocaldb stop "MSSQLLocalDB"
sqllocaldb delete "MSSQLLocalDB"
With the rogue database deleted, I went on to run init on the Azure Storage Emulator and all was fine again :)
C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe init
If you have multiple LocalDb instances installed and are not sure which one is the culprit you could just delete them all - the init call on the Azure Storage Emulator will just create the one it needs.
Just remember to back up any data you need before you delete.