Getting "NotImplementedException" when attempting Azure connection with Unity (c#)

Viewed 299

I'm using Unity 2019.3.6f1. I have created a simple DLL for connecting to Azure and uploading a file. However, when I call this DLL to attemp connecting to the Azure blob storage I get the following stack trace:

NotImplementedException: The method or operation is not implemented. System.Net.Http.HttpClientHandler.get_MaxConnectionsPerServer () (at <7ebf3529ba0e4558a5fa1bc982aa8605>:0) Azure.Core.Pipeline.ServicePointHelpers.SetLimits (System.Net.Http.HttpMessageHandler messageHandler) (at :0) Azure.Core.Pipeline.HttpClientTransport.CreateDefaultClient () (at :0) Azure.Core.Pipeline.HttpClientTransport..ctor () (at :0) Azure.Core.Pipeline.HttpClientTransport..cctor () (at :0) Rethrow as TypeInitializationException: The type initializer for 'Azure.Core.Pipeline.HttpClientTransport' threw an exception. Azure.Core.ClientOptions..ctor () (at :0) Azure.Storage.Blobs.BlobClientOptions..ctor (Azure.Storage.Blobs.BlobClientOptions+ServiceVersion version) (at :0) Azure.Storage.Blobs.BlobServiceClient..ctor (System.String connectionString, Azure.Storage.Blobs.BlobClientOptions options) (at :0) Azure.Storage.Blobs.BlobServiceClient..ctor (System.String connectionString) (at :0) Cineon.UnityToAzureConnection+d__1.MoveNext () (at <5252723c79f94a8cb77bb25e3b9f0396>:0) --- End of stack trace from previous location where exception was thrown --- System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () (at <437ba245d8404784b9fbab9b439ac908>:0) System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) (at <437ba245d8404784b9fbab9b439ac908>:0) UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () (at :0) UnityEngine.UnitySynchronizationContext:ExecuteTasks()

Here is my DLL code (in line with this Microsoft quickstart guide):

public class UnityToAzureConnection
{
    private readonly static string m_connectionString = "CENSORED";

    public static async void CreateConnection(string _path, string _fileName)
    {
        BlobServiceClient blobServiceClient = new BlobServiceClient(m_connectionString);
        BlobContainerClient containerClient = await blobServiceClient.CreateBlobContainerAsync("imagetest");

        BlobClient blobClient = containerClient.GetBlobClient(_fileName);
        using (FileStream _fs = File.Open(Path.Combine(_path, _fileName), FileMode.Open))
        {
            await blobClient.UploadAsync(_fs, true);
        }
    }
}

I simply call this DLL's CreateConnection method and pass in my "Application.dataPath" and a filename. However, I then get the above exception.

I have pulled all other needed DLL's from the project build folder into the plugin folder, so am unsure why this is occuring.

Any assistance would be greatly appreciated.

Please note that I am just starting to move out of my comfort zone here, so I'm hoping that my post is to StackOverflow's standard of questions.

[P.S.] Obviously "CENSORED" isn't my actual connection string, just keeping sensitive info hidden.

UPDATE 29/05/2021 I have confirmed that my connection code DOES work when used in a simple .net console app (however, I did have to adjust the containername to be all lowercase). This error only occurs in Unity. Again, any and all help would be appreciated.

2 Answers

I have experienced the same exception in BlobServiceClient constructor in my mobile project.

The problem was in the version of Azure.Storage.Blobs package. I used the most recent version 12.12.0, and it caused the exception.

When I downgraded Azure.Storage.Blobs package to 12.9.1 all things worked fine.

Related