I am currently working on a project that uses the legacy azure-storage-node package.
I have been working on migrating the whole application to use the upgraded packages, as recommended by Microsoft. I am following along using the Migration Guides for blobs, queues, and tables individually. I cannot find anywhere in the data-tables guide or the examples that mentions how to set up retry options.
Currently we have this code using the old SDK:
const azureStorage = require('azure-storage');
const retryOperations = new azureStorage.ExponentialRetryPolicyFilter();
const tableSvc = azureStorage.createTableService(<connectionString>).withFilter(retryOperations);
And the beginning of my new code:
const {
AzureNamedKeyCredential,
TableServiceClient,
TableEntity,
odata
} = require("@azure/data-tables");
const tableSvc = TableServiceClient.fromConnectionString(<connectionString>);
// .withFilter()
How can I apply the same retry options to tableSvc in my new code? I also need to do the same for my queues and blobs.
CodePudding user response:
2nd parameter for TableServiceClient.fromConnectionString
is the options and this is where you would specify the retry policy.
Something like:
const tableSvc = TableServiceClient.fromConnectionString(<connectionString>, {
retryOptions: {
maxRetries: 5,
maxRetryDelayInMs: 10000,
retryDelayInMs: 1000
}
});
Links to documentation:
TableServiceClientOptions: https://docs.microsoft.com/en-us/javascript/api/@azure/data-tables/tableserviceclientoptions?view=azure-node-latest
CommonClientOptions: https://docs.microsoft.com/en-us/javascript/api/@azure/core-client/commonclientoptions?view=azure-node-latest
PipelineRetryOptions: https://docs.microsoft.com/en-us/javascript/api/@azure/core-rest-pipeline/pipelineretryoptions?view=azure-node-latest