Fix: Azurite — Exit due to unhandled error: Unexpected token
Today my C# Azure Function had troubles starting when launched from Visual Studio 2022. I realized that Azurite, the new local Azure Storage Emulator had not started properly when the Azure Function project was loaded.
Under Output => Service Dependencies you can verify the Azurite startup has been triggered like this:
azurite.cmd -location “C:\Users\UserName\AppData\Local\Temp\Azurite” — debug “C:\Users\UserName\AppData\Local\Temp\Azurite\debug.log” — skipApiVersionCheck
However, instead of getting the local storage endpoints I just received the following error message:
Exit due to unhandled error: Unexpected token in JSON at position 0
Since Google didn’t give me a good answer I tried to simply delete the temp folder which luckily resolved my issues. So if you get a similar message, just go ahead and clear out this folder (which, btw. gave me back 2 GB for the debug.log file alone):
%LOCALAPPDATA%\Temp\Azurite