支持WindowsAzure的Azure表存储中的RetyPolicy。存储SDK版本7.0.0.0

支持WindowsAzure的Azure表存储中的RetyPolicy。存储SDK版本7.0.0.0,azure,azure-storage,azure-table-storage,azure-sdk-.net,Azure,Azure Storage,Azure Table Storage,Azure Sdk .net,我需要为所有表操作应用自定义重试策略。这就是我一直在使用的: _account = CloudStorageAccount.Parse(PhoenixConfiguration.AzureBlobStorageConnection); var _tableClient = this._account.CreateCloudTableClient(); IRetryPolicy linearRetryPolicy = new LinearRetry(TimeSpan.FromSeconds(5),

我需要为所有表操作应用自定义重试策略。这就是我一直在使用的:

_account = CloudStorageAccount.Parse(PhoenixConfiguration.AzureBlobStorageConnection);
var _tableClient = this._account.CreateCloudTableClient();
IRetryPolicy linearRetryPolicy = new LinearRetry(TimeSpan.FromSeconds(5), 10);
_tableClient.RetryPolicy = linearRetryPolicy;

我使用的是WindowsAzure.Storage SDK(版本6),在将我的项目升级为使用WindowsAzire.Storage SDK版本7后,此代码正在中断。在新SDK中实现自定义重试策略的正确方法是什么?是否有任何文档可供我参考?

您的代码未能编译的原因是
CloudTableClient
上的
RetryPolicy
成员在6.0版中被弃用,现在在7.0版中被删除[令人惊讶的是,
CloudBlobClient
上仍然有它,尽管它已弃用]

要使用
重试策略
,必须使用
TableRequestOptions
并在此处指定重试策略。例如,这就是创建表时可以使用它的方式

        var storageAccount = new CloudStorageAccount(new StorageCredentials(accountName, accountKey), true);
        IRetryPolicy linearRetry = new LinearRetry(TimeSpan.FromSeconds(5), 10);
        var tableClient = storageAccount.CreateCloudTableClient();
        var table = tableClient.GetTableReference("MyTable");
        var tableRquestOptions = new TableRequestOptions()
        {
            RetryPolicy = linearRetry
        };
        table.CreateIfNotExists(tableRquestOptions);

你的错误是什么?编译错误。TableClient类似乎不再支持RetryPolicy属性。谢谢您的回答。尽管RetryPolicy仍然存在,但BlobClient仍然存在,我在运行时遇到了一个奇怪的错误。我的本地模拟器抛出了一个错误,表示该操作是不允许的。嗯……我自己没有尝试过,所以我不知道。但我建议不要在客户机对象上指定重试策略,而是在操作级别指定,因为它们可能随时被删除。