使用重试策略后配置 Azure 存储帐户时出错
Error in Configuring Azure Storage Account after using Retry Policies
这是我配置 Azure 存储帐户的代码
public CloudTableClient ConfigureStorageAccount()
{
var storageCred = new StorageCredentials(ConfigurationManager.AppSettings["SASToken"]);
CloudTableClient = new CloudTableClient(
new StorageUri(new Uri(ConfigurationManager.AppSettings["StorageAccountUri"])), storageCred);
var backgroundRequestOption = new TableRequestOptions()
{
// Client has a default exponential retry policy with 4 sec delay and 3 retry attempts
// Retry delays will be approximately 3 sec, 7 sec, and 15 sec
MaximumExecutionTime = TimeSpan.FromSeconds(30),
// PrimaryThenSecondary in case of Read-access geo-redundant storage, else set this to PrimaryOnly
LocationMode = LocationMode.PrimaryThenSecondary,
};
CloudTableClient.DefaultRequestOptions = backgroundRequestOption;
return CloudTableClient;
}
当我指定 backgroundRequestOption
时出现错误 未指定目标存储位置的 Uri。请考虑更改请求的定位模式。
当我不指定 backgroundRequestOption
时,我不会收到任何错误。我需要在哪里指定这个 URI?
如果选择 LocationMode.PrimaryThenSecondary,您需要同时指定 PrimaryUri 和 SecondaryUri。
这是我配置 Azure 存储帐户的代码
public CloudTableClient ConfigureStorageAccount()
{
var storageCred = new StorageCredentials(ConfigurationManager.AppSettings["SASToken"]);
CloudTableClient = new CloudTableClient(
new StorageUri(new Uri(ConfigurationManager.AppSettings["StorageAccountUri"])), storageCred);
var backgroundRequestOption = new TableRequestOptions()
{
// Client has a default exponential retry policy with 4 sec delay and 3 retry attempts
// Retry delays will be approximately 3 sec, 7 sec, and 15 sec
MaximumExecutionTime = TimeSpan.FromSeconds(30),
// PrimaryThenSecondary in case of Read-access geo-redundant storage, else set this to PrimaryOnly
LocationMode = LocationMode.PrimaryThenSecondary,
};
CloudTableClient.DefaultRequestOptions = backgroundRequestOption;
return CloudTableClient;
}
当我指定 backgroundRequestOption
时出现错误 未指定目标存储位置的 Uri。请考虑更改请求的定位模式。
当我不指定 backgroundRequestOption
时,我不会收到任何错误。我需要在哪里指定这个 URI?
如果选择 LocationMode.PrimaryThenSecondary,您需要同时指定 PrimaryUri 和 SecondaryUri。