On our AX "OneBox" dev environments, there was already a scheduled task DynamicsStartAzureStorageEmulator
that launches the emulator as NT AUTHORITY\SYSTEM on startup. Azure Storage Emulator was upgraded (Automatically? By the devs?), and then it stopped working.
The issue was twofold:
It was trying to use the LocalDB(SQL Express Subset) instance
It needed to initialize a new DB, as SYSTEM.
(Example, before it was AzureStorageEmulatorDB49
, now it's AzureStorageEmulatorDB510
)
Once I ran a shell/cmd as SYSTEM (using PSEXEC, and tried to run the emulator to see the error output, the rest was pretty straightforward.
The solution was pretty much just: Run shell as system (Using Psexec)
PsExec.exe -i -s cmd
And as SYSTEM, init the new database (in our case, using "Real" SQL, rather than LocalDB/Express.):
AzureStorageEmulator.exe init -server localhost
(If you want to stick w/ LocalDB, AzureStorageEmulator.exe init
should work just fine)
As it was multiple VMs, I used powershell remoting:
$ListOfHostnames | foreach {.\PsExec.exe \\$_ -i -s "C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe" init -server localhost}
(Yes, if you have PwSH 7, you can use -parallel ;)
After that, it was a simple reboot to verify it all came up automatically.
Additional items:
I set the scheduled task to also just start once a day at like 5 am, just in case it wasn't running for some reason.
Some envs had an emulator DB on the LocalDB instance, which I deleted. Not strictly necessary, just cleaner.
References:
https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator#initialize-the-storage-emulator-to-use-a-different-sql-database and
https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator#command-line-syntax