Neo4j and Azure Deployment Improvement

We’ve learned how to run Neo4j on Azure using VS 2010 or VS 2012 thanks to these two blog posts: by Chris Skardon and by Magnus Mårtensson and Peter Neubauer.

The VS solution provided by Neo4j is a great starter, but there are still quite a few steps involved and one needs to fix some issues when deploying on Azure. I have combined the effort from those guys, and created a new Solution that works in both VS 2010, and VS 2012, and streamline the process to deploy Neo4j on Azure. The new solution:

  • Upload the Neo4j and JRE to Azure Storage
  • Utilize Azure CloudDrive for storage
  • Run on both VS 2010, and VS 2012
  • Open the Neo4j ports to external (accessible outside of your Server/Localhost)
  • Fix up some hiccups to run on Azure Worker Role (such as JRE path)
  • Clean up some code and hardcoded path to the settings

So, let’s get started shall we? Please download the new solution from here. Then open Neo4j.Azure.Server.vs2010.sln if you are using VS 2010, and Neo4j.Azure.Server.sln if you are using VS 2012. Use NuGet Package Manager Console to restore all the missing packages (See here for NuGet documentations), do a full build, and follow the steps below to deploy.

Open the VS solution

Step 1: Run the console application Neo4jUploader to upload the Neo4j and JRE to Azure Storage
The code was provided by Chris, and I have expanded a little bit more to let you upload the files to Local or Cloud Azure Storage. If you want to upload the Neo4j and JRE to Cloud, make sure you change the storage connection string:

Edit the Connection String

Step 2: Run Neo4j.Azure.Server to start the local Azure emulator
Once the project is launched, you will see the Java console window loaded. Just go to this URL: and if you see the web admin for Neo4j, you are in business!

A) Now, you are ready to deploy this to your Azure Worker Role. To configure for Cloud, you need to change a few settings in ServiceConfiguration.csfg. Replace the UseDevelopmentStorage with your Azure connection string in this format: DefaultEndpointsProtocol=https;AccountName=;AccountKey=
Edit the Storage Connection String

B) The original solution comes with the code to integrate with CloudDrive, but it was not hook up. This new solution will mount the CloudDrive and save the database to the .vhd in your Azure Storage. This setting allows you to allocate the size of your clouddrive:

Edit the Cloud Drive Size

C) You may want to change the port to something else. Just go to the properties of the Neo4jServerHost and alter the port.
Port Number

With this configured, you can try to deploy to Azure. You can open the Web Admin from the URL: I hope this solution helps you.

Some Potential Issues:
When running local Azure emulator, you may get into this error when unzipping the Neo4j binaries.

“The path is too long after being fully qualified. Make sure the full path is less than 260 characters and the directory name is less than 248 characters.”

The problem is that path combined from the Azure temp directory with Neo4j binaries exceeded 260 characters. The easiest way for me to get around is to change the Azure temp directory by following this blog:

In addition, when running the Neo4j on your Azure emulator, you may get the “ Address already in use: JVM_Bind” exception. You can try to workaround this problem by setting a Private Port. I am not sure why and what caused the problem in the first place, as I am no longer able to reproduce this problem anymore.

So what is Next?
Neo4j does not have an build-in authentication or user management. You will notice that anyone can connect to your graph database with the URL and there is just no security. Our next post will talk about how to secure the port for Azure Roles communication.

Thanks, feel free to contact me if you run into any issues,
Raymond Tsang
t: @tsanglwr

By Raymond Tsang

Tagged with: , ,
Posted in Azure, Technical