Azure table 使用 NodeJs SDK 进行存储故障转移

Azure table storage failover using NodeJs SDK

我已将 Azure Table 存储帐户配置为 RA-GRS 并使用以下代码访问它:

const host = {
    primaryHost: `https://${primaryAccountName}.table.core.windows.net`,
    secondaryHost: `https://${primaryAccountName}-secondary.table.core.windows.net`
  };
var tableSvc = azure.createTableService(primaryAccountName, accessKey, host);
const entGen = azure.TableUtilities.entityGenerator;
const locationMode = azure.StorageUtilities.LocationMode;
const tableName = 'testTable';

  const options = {
    locationMode: locationMode.PRIMARY_THEN_SECONDARY,
    requestLocationMode: locationMode.PRIMARY_THEN_SECONDARY
   };
  tableSvc.retrieveEntity(tableName, 'hometasks', '1', options, function(error, result, response){
    if(error){
      console.log('Error on retrieveEntity!', error, result, response);
    } else {
      console.log('Entity retrieved', result.published._);
    }
  });

我手动启动了故障转移,预计故障转移完成后,它会选择新帐户并继续工作,但它没有,并因以下错误而失败:

Error on retrieveEntity! Error: getaddrinfo ENOTFOUND test0failover-secondary.table.core.windows.net

有什么办法可以顺利过渡到副账号吗?我正在寻找的是在发生故障转移时具有对辅助帐户的读取权限。

发生这种情况是因为一旦您进行手动故障转移,故障转移完成后您的存储帐户将变为本地冗余 (LRS)。您将必须将该帐户手动转换为异地冗余(RAGRS 或 GRS)。

从这个link:

After the failover, your storage account type is automatically converted to locally redundant storage (LRS) in the new primary region. You can re-enable geo-redundant storage (GRS) or read-access geo-redundant storage (RA-GRS) for the account. Note that converting from LRS to GRS or RA-GRS incurs an additional cost. For additional information, see Bandwidth Pricing Details.

After you re-enable GRS for your storage account, Microsoft begins replicating the data in your account to the new secondary region. Replication time is dependent on the amount of data being replicated.