你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

BlobRequestOptions.LocationMode 属性

定义

获取或设置请求的位置模式。

public Microsoft.Azure.Storage.RetryPolicies.LocationMode? LocationMode { get; set; }
member this.LocationMode : Nullable<Microsoft.Azure.Storage.RetryPolicies.LocationMode> with get, set
Public Property LocationMode As Nullable(Of LocationMode)

属性值

指示请求位置模式的 LocationMode 枚举值。

实现

示例

// The PrimaryOnly LocationMode directs the request and all potential retries to go to the primary endpoint.
BlobRequestOptions locationModeRequestOptions = new BlobRequestOptions() { LocationMode = RetryPolicies.LocationMode.PrimaryOnly };
byteCount = blob.DownloadToByteArray(destinationArray, index: 0, accessCondition: null, options: locationModeRequestOptions);

// The PrimaryThenSecondary LocationMode directs the first request to go to the primary location.
// If this request fails with a retryable error, the retry will next hit the secondary location.
// Retries will switch back and forth between primary and secondary until the request succeeds, 
// or retry attempts have been exhausted.
locationModeRequestOptions = new BlobRequestOptions() { LocationMode = RetryPolicies.LocationMode.PrimaryThenSecondary };
byteCount = blob.DownloadToByteArray(destinationArray, index: 0, accessCondition: null, options: locationModeRequestOptions);

// The SecondaryOnly LocationMode directs the request and all potential retries to go to the secondary endpoint.
locationModeRequestOptions = new BlobRequestOptions() { LocationMode = RetryPolicies.LocationMode.SecondaryOnly };
byteCount = blob.DownloadToByteArray(destinationArray, index: 0, accessCondition: null, options: locationModeRequestOptions);

// The SecondaryThenPrimary LocationMode directs the first request to go to the secondary location.
// If this request fails with a retryable error, the retry will next hit the primary location.
// Retries will switch back and forth between secondary and primary until the request succeeds, or retry attempts
// have been exhausted.
locationModeRequestOptions = new BlobRequestOptions() { LocationMode = RetryPolicies.LocationMode.SecondaryThenPrimary };
byteCount = blob.DownloadToByteArray(destinationArray, index: 0, accessCondition: null, options: locationModeRequestOptions);

注解

LocationMode 指定存储客户端将尝试在哪些位置发出请求。 这仅对 RA-GRS 帐户有效- 可从主终结点或辅助终结点读取数据的帐户。

适用于