The Mixed Reality Forums here are no longer being used or maintained.
There are a few other places we would like to direct you to for support, both from Microsoft and from the community.
The first way we want to connect with you is our mixed reality developer program, which you can sign up for at https://aka.ms/IWantMR.
For technical questions, please use Stack Overflow, and tag your questions using either hololens or windows-mixed-reality.
If you want to join in discussions, please do so in the HoloDevelopers Slack, which you can join by going to https://aka.ms/holodevelopers, or in our Microsoft Tech Communities forums at https://techcommunity.microsoft.com/t5/mixed-reality/ct-p/MicrosoftMixedReality.
And always feel free to hit us up on Twitter @MxdRealityDev.
How to connect HoloLens to Azure services.

Hey WHDF,
This is like my third question in a week but I am starting to get the hang of how the Hololens works with everything and maybe it will help someone in the future . I was wondering though how do you connect the hololens to azure like in:
https://blogs.windows.com/devices/2016/09/15/microsoft-hololens-enables-thyssenkrupp-to-transform-the-global-elevator-industry/
I found out that the HoloLens does not support Azure.servicebus from nuget and that the nuget package that works mobile.client requires you to publish an app to the store for push notifications which is way to much for a fun Poc project.
Does anyone know how to get the HoloLens to connect with Azure and if it's possible with for example the IoT services like in the case?
Thank you already,
Kr,
TvT
Best Answers
-
jbienzms mod
This is an area of confusion for folks because Unity Editor and Unity exported to HoloLens are actually two different environments.
Unity Editor runs Mono and has no access to UWP APIs. But once the app has been exported to Visual Studio it becomes a full fledged UWP app.
UWP code (and even NuGet libraries) CAN be used in a HoloLens app. I'm actually working on a HoloLens Deep Dive course right now and one of the sections of that course explains how to do this.
NOTE: If you live in the Boston area or can get to the Boston area 3/28/17 - 3/30/17 I still have a few seats available for the first delivery of this Deep Dive class. It is not being publicly announced, but e-mail me at jbienz at Microsoft com if you are interested.
I wish I had this material ready to share with you now, but I'll try to summarize.
- The NuGet package must be downloaded using the command line so you can get all versions of the library. For example, make a temporary folder, go there at the command prompt and run nuget install Newtonsoft.Json
- You will need the UWP version of the library for HoloLens and a classic .Net 2.0 (or sometimes 3.5) version of the library for the Unity editor. Not all NuGet packages support both. If the package doesn't support both, you'll have to use conditional compile statements to hide code from the Unity Editor that won't run there (that code will only work when exported and run on HoloLens).
- Using Newtonsoft.Json as the example, you'll need the net35 version for the Unity Editor and the portable-net45 version for UWP. Both dlls are copied into your Unity project and you use the Unity Plugin Inspector to mark them accordingly.
- The net35 version should be marked as 'Any' with 'WSAPlayer' excluded.
- The portable-net45 version should be marked as 'WSAPlayer' only.
Now you have Newtonsoft.json in your Unity project and you can use their APIs both in the Editor and at runtime on the HoloLens.
If you need to use a NuGet package that doesn't support Mono (net20 or net35) you will not be able to call those APIs when you're in the Unity Editor. In fact, what you'll see are compilation errors telling you that those APIs don't even exist. Remember, they don't exist in the Unity Editor because they're not compatible with Mono. But they WILL exist once you export the project to Visual Studio.
In this case you can surround your using statements and your calls into those APIs with conditional compile statements. But keep in mind you still need some kind of placeholder code that runs while you're in the Editor so you know that work is getting done.
Here's a pseudo example of how I called UWP code in the TextToSpeechManager that's part of the toolkit:
#if WINDOWS_UWP synthesizer = new SpeechSynthesizer(); synthesizer.SynthesizeTextToStreamAsync(text); #else Debug.LogFormat("Would have said \"{0}\"", text); #endif
Finally, there's a good chance you'll need to deal with threading issues. Unity doesn't understand Task, Async or Await. To get around this, you'll need to start a Task to execute code, but then you need to call back into Unity's thread to signal that the work is complete or to interact with any Unity objects.
Again, this is a whole topic all on its own and I could spend a day on it alone. But here's a bit of code that does what I'm talking about:
Task.Run(async () => { // UWP code which uses await ... // Schedule notification back on Unity thread Application.InvokeOnAppThread(() => { // Access Unity objects / notify completion ... }, false); }
The Application object in that snippet above is UnityEngine.WSA.Application, not the UWP Application class.
Sorry, this is not a beginner topic. It's pretty advanced. But if you understand it you can leverage a massive list of libraries available to you out on NuGet as well as all the APIs available to you in the UWP.
For a complete example of how to call UWP APIs, including dealing with conditional compiling and threading, please see TextToSpeechManager.
And if / when I convert that slide deck to an article, I'll come back and link it here.
Our Holographic world is here
RoadToHolo.com WikiHolo.net @jbienz
I work in Developer Experiences at Microsoft. My posts are based on my own experience and don't represent Microsoft or HoloLens.5 -
jbienzms mod
@Tvt It sounds like you may be trying to leverage the SERVER version of the Service Bus library, which is not going to run on HoloLens. You need a version of the library that is compatible with UWP.
I have not attempted this before, but it does appear that this library is intended to be used in client applications and potentially works with UWP. The NuGet Package for that library is Microsoft.Azure.Management.ServiceBus. Since I haven't actually attempted to use this library on HoloLens, I'm sorry that I can't give you much more guidance than that. However, I will point out that this library does not appear to support .Net 2.0 or 3.5, which means it will not work in the Editor. You will need to use conditional compile statements and placeholder code for when you're in the editor.
Sorry I can't offer more guidance. I hope this points you in the right direction.
Our Holographic world is here
RoadToHolo.com WikiHolo.net @jbienz
I work in Developer Experiences at Microsoft. My posts are based on my own experience and don't represent Microsoft or HoloLens.5
Answers
Unfortunately I have been down this path before Microsoft Azure Services are NOT supported on HoloLens. HoloLens startup should be viewed as a Windows Phone on Startup. Although many services exist they are not supported and getting UWP support for Azure does not happen on HoloLens
@Jimbohalo10 well that is unfortunate, Do you know of any unofficial way to make it work then? Or should i just drop it all together.
The complexity of using Azure is so high, you have to BUY Technical Support from the Azure Support teams.
Reluctantly I dropped Azure, also note that Azure cannot run the HoloLens Emulator or mobile services as Azure uses virtual space for itself!.
@Jimbohalo10 yea I figured.. Trying with Rest now but it's not your basic Rest api calls. If I find a way I will post the actual solution. Support unfortunately is not an option.
This is an area of confusion for folks because Unity Editor and Unity exported to HoloLens are actually two different environments.
Unity Editor runs Mono and has no access to UWP APIs. But once the app has been exported to Visual Studio it becomes a full fledged UWP app.
UWP code (and even NuGet libraries) CAN be used in a HoloLens app. I'm actually working on a HoloLens Deep Dive course right now and one of the sections of that course explains how to do this.
I wish I had this material ready to share with you now, but I'll try to summarize.
Now you have Newtonsoft.json in your Unity project and you can use their APIs both in the Editor and at runtime on the HoloLens.
If you need to use a NuGet package that doesn't support Mono (net20 or net35) you will not be able to call those APIs when you're in the Unity Editor. In fact, what you'll see are compilation errors telling you that those APIs don't even exist. Remember, they don't exist in the Unity Editor because they're not compatible with Mono. But they WILL exist once you export the project to Visual Studio.
In this case you can surround your using statements and your calls into those APIs with conditional compile statements. But keep in mind you still need some kind of placeholder code that runs while you're in the Editor so you know that work is getting done.
Here's a pseudo example of how I called UWP code in the TextToSpeechManager that's part of the toolkit:
Finally, there's a good chance you'll need to deal with threading issues. Unity doesn't understand Task, Async or Await. To get around this, you'll need to start a Task to execute code, but then you need to call back into Unity's thread to signal that the work is complete or to interact with any Unity objects.
Again, this is a whole topic all on its own and I could spend a day on it alone. But here's a bit of code that does what I'm talking about:
The Application object in that snippet above is UnityEngine.WSA.Application, not the UWP Application class.
Sorry, this is not a beginner topic. It's pretty advanced. But if you understand it you can leverage a massive list of libraries available to you out on NuGet as well as all the APIs available to you in the UWP.
For a complete example of how to call UWP APIs, including dealing with conditional compiling and threading, please see TextToSpeechManager.
And if / when I convert that slide deck to an article, I'll come back and link it here.
Our Holographic world is here
RoadToHolo.com WikiHolo.net @jbienz
I work in Developer Experiences at Microsoft. My posts are based on my own experience and don't represent Microsoft or HoloLens.
@jbienzms thanks a lot. It's a lot to consume though and I am wondering if this would work for the azure.servicebus since you just cannot change every .dll to .Net35
Also the conditional compiling might be a solution for other problems I am facing. I was trying to create a separate .dll but this also seems to have problems with the .net version and it doesn't seem that easy to compile an old .net35 library in VS2015.
It doesn't seem like MS even wants you to do this since they make it such a pain to peform anyways even when using rest..
@jbienzms How do you make sure that the .dll's are actually exported to the project? When i export it from unity the .dll files do not port with it.
@Tvt It sounds like you may be trying to leverage the SERVER version of the Service Bus library, which is not going to run on HoloLens. You need a version of the library that is compatible with UWP.
I have not attempted this before, but it does appear that this library is intended to be used in client applications and potentially works with UWP. The NuGet Package for that library is Microsoft.Azure.Management.ServiceBus. Since I haven't actually attempted to use this library on HoloLens, I'm sorry that I can't give you much more guidance than that. However, I will point out that this library does not appear to support .Net 2.0 or 3.5, which means it will not work in the Editor. You will need to use conditional compile statements and placeholder code for when you're in the editor.
Sorry I can't offer more guidance. I hope this points you in the right direction.
Our Holographic world is here
RoadToHolo.com WikiHolo.net @jbienz
I work in Developer Experiences at Microsoft. My posts are based on my own experience and don't represent Microsoft or HoloLens.
@jbienzms thanks i already found that one and tried it and it work till you get to the encryption part. You cannot connect to azure without security so it's a no-go for now.
Thanks for all the support!
I haven't tried this combo personally, but you could try using the REST APIs for service bus + the UnityWebRequest class in unity to make basic HTTP calls. It may be more work that using the SDKs but it may enable something.
https://www.billmccrary.com/
@BillMcCrary haha damn man this is exactly what i am doing right now. it feels kinda hacky but works.
Hi,
Did anyone tried to calculate potential Azure consumption for a Hololens development project?
Regards,
Marko