0

My function stores data up Azure Data Lakta Storage Gen 1. But I got bug

An error occurred while sending the request.
When I investigated,I knowed that my connection in azure function overcome 8k then it's broken. Here is my code(Append to file Azure DataLakeStorage Gen 1)
//This for authorizing azure data lake storage gen 1
 await InitADLInfo(adlsAccountName);

DataLakeStoreFileSystemManagementClient _adlsFileSystemClient;

//Here is my code to append data lake storage gen 1
 using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(buffer)))
 {
    await _adlsFileSystemClient.FileSystem.AppendAsync(_adlsAccountName, path, stream);                         
 }

How to dispose that when every append ends. I try to dispose

_adlsFileSystemClient.Dispose();

But it didn't dispose anything.My connection will up.

Duc Dang
  • 23
  • 1
  • 1
  • 9
  • you can use using DataLakeStoreFileSystemManagementClient clause since it implements IDisposable – Aravind Apr 03 '19 at 09:19
  • Tks for reply.I used to using DataLakeStoreFileSystemManagementClient but it wasn't still dispose – Duc Dang Apr 04 '19 at 03:36
  • It will. that is the purpose of the using statement. https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/statements#the-using-statement – Aravind Apr 05 '19 at 06:30

1 Answers1

0

I read this https://www.troyhunt.com/breaking-azure-functions-with-too-many-connections/1 and I have made connection down.Just use DO NOT create a new client with every function invocation. Example Code :

// Create a single, static HttpClient
private static HttpClient httpClient = new HttpClient();

public static async Task Run(string input)
{
    var response = await httpClient.GetAsync("http://example.com");
    // Rest of function
}
Duc Dang
  • 23
  • 1
  • 1
  • 9