azure - 如何处理与 Azure 存储等服务的连接
问题描述
我的函数将数据存储到 Azure Data Lakta Storage Gen 1。但我遇到了错误
发送请求时出错。当我调查时,我知道我在 azure 函数中的连接超过了 8k,然后它就坏了。这是我的代码(附加到文件 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);
}
当每个附加结束时如何处理它。我尝试处置
_adlsFileSystemClient.Dispose();
但它没有处理任何东西。我的连接会起来。
解决方案
我读了这个
https://www.troyhunt.com/break-azure-functions-with-too-many-connections/ 1
我已经建立了连接。只需使用DO NOT create a new client with every function invocation.
示例代码:
// 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
}
推荐阅读
- python - 用局部均值填充 0
- javascript - 如何获取 JSON 数据并将其解析为 jquery 中的数组?
- python - 将熊猫数据框行拆分为新的数据框,直到搜索到的列值
- node.js - 错误:签名验证失败 jwt-simple nodejs
- typescript - 具有特定键和值集的 TypeScript 类型
- angular - 通过 Transloco 加载的数组上的 Angular ngFor
- google-apps-script - setbackground 在谷歌表格中不起作用
- javascript - vega-lite:多个图表中的同步选择
- php - PHP Gmail API 获取发件人、收件人、抄送、密送、回复、正文、附件的邮件信息
- python - 使用 PyCamera 注释文本