node.js - Azure存储NodeJS修改默认超时设置

标签 node.js azure-storage azure-blob-storage

我想知道是否可以更改 Azure 存储 BlobService 的默认超时设置。从文档中我可以看到默认设置是:

  • 获取 blob、获取页面范围或获取阻止列表的调用每兆字节允许 2 分钟完成。如果某个操作平均每兆字节花费的时间超过 2 分钟,就会超时。

  • 写入 blob、写入 block 或写入页的调用每兆字节允许 10 分钟完成。如果某个操作平均每兆字节花费的时间超过 10 分钟,则会超时。

查看源代码,我发现 BlobService.getServiceProperties 和 setServiceProperties 列出了这两个参数:

  • @param {int} [options.timeoutIntervalInMs] 用于请求的服务器超时间隔(以毫秒为单位)。
  • @param {int} [options.maximumExecutionTimeInMs] 发出此请求时使用的所有潜在重试的最大执行时间(以毫秒为单位)。最大执行时间间隔从客户端开始构建请求的时间开始。在执行请求时和执行重试之前会间歇性地检查最大执行时间。

这两个参数与上面的项相同吗?

现在,当我尝试使用以下代码使用 getServiceProperties 时,除了日志记录、指标和 cors 数据之外,我没有得到任何信息。 Github 页面上是这么说的

blobSvc.getServiceProperties(function(error, result, response) {
    if (!error) {
        console.log('Result: ', result);
        console.log('Response: ', response);
    } else {
        console.log(error);
    }
});

Result:  { Logging:
   { Version: '1.0',
     Delete: false,
     Read: false,
     Write: false,
     RetentionPolicy: { Enabled: false } },
  HourMetrics:
   { Version: '1.0',
     Enabled: true,
     IncludeAPIs: true,
     RetentionPolicy: { Enabled: true, Days: 7 } },
  MinuteMetrics:
   { Version: '1.0',
     Enabled: false,
     RetentionPolicy: { Enabled: false } },
  Cors: {} }
Response:  { isSuccessful: true,
  statusCode: 200,
  body:
   { StorageServiceProperties:
      { Logging: [Object],
        HourMetrics: [Object],
        MinuteMetrics: [Object],
        Cors: '' } },
  headers:
   { 'transfer-encoding': 'chunked',
     'content-type': 'application/xml',
     server: 'Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0',
     'x-ms-request-id': '45a3cfeb-0001-0127-0cf7-0149a8000000',
     'x-ms-version': '2015-02-21',
     date: 'Thu, 08 Oct 2015 18:32:36 GMT',
     connection: 'close' },
  md5: undefined }

所以我真的想我对文档之间的不匹配以及是否可以修改任何超时设置感到困惑。

最佳答案

带有超时选项的示例调用是:

var options = { maximumExecutionTimeInMs: 1000 };
blobSvc.createBlockBlobFromLocalFile('mycontainer', 'myblob', 'test.txt', options, function(error, result, response) {
  if(!error) { 
    // file uploaded 
  } 
});

您可能还想检查 API 及其选项:http://azure.github.io/azure-storage-node/BlobService.html

关于node.js - Azure存储NodeJS修改默认超时设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33023774/

相关文章:

node.js - 使用 Azure AD 承载 token 时身份验证失败,无法返回容器列表 [Azure Blob] [Azure AD OAuth 2.0] [REST API]

javascript - ReadStream和WriteStream到nodejs中的同一个文件

node.js - 在 Sails.js 中设置 cookie 过期时间

Azure EventHub EventProcessorHost 存储帐户问题 : Out of retries creating lease for partition

c# - 使用共享访问 key 上传到 Azure Blob 存储

c# - 列出 Azure Blob 客户端中的所有容器 - 缺少 ListContainers 方法?

azure - 使用 sFTP 服务面向 Azure 存储 blob

node.js - 每次服务器重新启动时散列模式都会更改

javascript - 通过 R 和子进程在错误的目录中创建文件

.net - Azure 表存储插入或替换结果