Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Attempting to connec to Azure Blobs results in NotImplementedException

Discussion in 'Scripting' started by Tset_Tsyung, May 29, 2021.

  1. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Hey all,

    Okay, so I've been battling with getting Unity to talk to Azure for uploading Blobs (Binary Large Objects). After experimenting in a .net console app and a DLL project I can connect my console app to azure using my DLL (the DLL follows this MSDN Quickstart guide).

    This works! I can upload files to my azure test server and see the containers and blobs.

    However, as soon as I try to run this DLL (along with it generated dependancy DLL's) in Unity I get the following error:

    Code (CSharp):
    1. NotImplementedException: The method or operation is not implemented.
    2. System.Net.Http.HttpClientHandler.get_MaxConnectionsPerServer () (at <7ebf3529ba0e4558a5fa1bc982aa8605>:0)
    3. Azure.Core.Pipeline.ServicePointHelpers.SetLimits (System.Net.Http.HttpMessageHandler messageHandler) (at <e2a9da0afcdd4b63880cd5fb9da69ce0>:0)
    4. Azure.Core.Pipeline.HttpClientTransport.CreateDefaultClient () (at <e2a9da0afcdd4b63880cd5fb9da69ce0>:0)
    5. Azure.Core.Pipeline.HttpClientTransport..ctor () (at <e2a9da0afcdd4b63880cd5fb9da69ce0>:0)
    6. Azure.Core.Pipeline.HttpClientTransport..cctor () (at <e2a9da0afcdd4b63880cd5fb9da69ce0>:0)
    7. Rethrow as TypeInitializationException: The type initializer for 'Azure.Core.Pipeline.HttpClientTransport' threw an exception.
    8. Azure.Core.ClientOptions..ctor () (at <e2a9da0afcdd4b63880cd5fb9da69ce0>:0)
    9. Azure.Storage.Blobs.BlobClientOptions..ctor (Azure.Storage.Blobs.BlobClientOptions+ServiceVersion version) (at <c2ada25c5732479e8567df038fde890c>:0)
    10. Azure.Storage.Blobs.BlobServiceClient..ctor (System.String connectionString, Azure.Storage.Blobs.BlobClientOptions options) (at <c2ada25c5732479e8567df038fde890c>:0)
    11. Azure.Storage.Blobs.BlobServiceClient..ctor (System.String connectionString) (at <c2ada25c5732479e8567df038fde890c>:0)
    12. Cineon.UnityToAzureConnection+<CreateConnection>d__1.MoveNext () (at <64e720b8af2d44a0aa270a49adeb9a27>:0)
    13. --- End of stack trace from previous location where exception was thrown ---
    14. System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <437ba245d8404784b9fbab9b439ac908>:0)
    15. System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state) (at <437ba245d8404784b9fbab9b439ac908>:0)
    16. UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at <d815b7efac424eeb8e053965cccb1f98>:0)
    17. UnityEngine.UnitySynchronizationContext:ExecuteTasks()
    18.  
    Using DLL, connecting to Azure and developing in Vanilla VS2019/DotNet is all still very new to me, yet despite researching and banging my head against a wall I can't get past this particular hurdle.

    FULL DISCLOSURE: I have post some of my troubles on answers.unity.com and stackoverflow. But after this recent success of getting SOME kind of connection to Azure I will update those Q's and mark them as solved - they were mainly with getting the DLL's into Unity which I've done.

    I sincerely hope that someone has had a simliar DLL import issue and can help point me in the right direction. I will upload my code shortly.
     
  2. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,061
    Unity is not using .Net but mono and also not the latest version. The Azure library is trying to access
    HttpClientHandler.MaxConnectionsPerServer
    , which hasn't been implemented in older version of mono.

    Unity is working on upgrading mono and mono has been moving towards using the same class libraries as .Net, which will reduce issues like this in the future. You can check the status of this in Unity Future .NET Development Status, the gist is that it might drop in 2021.2 but likely later.

    But for now, the Azure SDK likely won't easily work in Unity. You could try to create a custom build of the SDK that removes the call but there could be other incompatibilities besides this one. You could try searching for a different Azure library that works in Unity (the ones I've found seem to be old and abandoned) or implement the REST API directly in Unity.

    Ultimately, as Unity notes in the Overview of .NET in Unity documentation:
    i.e. if a library doesn't explicitly support Unity, you should expect compatibility issues when you try to use it in Unity.
     
  3. Tset_Tsyung

    Tset_Tsyung

    Joined:
    Jan 12, 2016
    Posts:
    411
    Hi @Adrian,

    Many thanks for the reply. This makes it all much clearer. I now have several new avenues to investigate and I really appreciate your comprehensive answer.

    I'll post my final progress in this thread (if I do actually make any progress) for posterity.

    Again, many thanks. Stay safe and sane.

    Mike
     
  4. ambid17

    ambid17

    Joined:
    Jun 28, 2017
    Posts:
    7
    @Test_Tsyung

    Did you happen to find a workaround for this? I am running into the exact same issue
     
  5. akiojin

    akiojin

    Joined:
    Nov 1, 2012
    Posts:
    4
    NET dlls in the Plugins for Unity 2021.2.7f1 and it works fine.

    Azure.Core : ver.1.21.0
    Azure.Storage.Blobs : ver.12.10.0
    Azure.Storage.Common : ver.12.9.0

    For your reference