2017-04-26 42 views
2

後,這是我的代碼配置Azure存儲帳戶錯誤配置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?

回答

4

如果選擇了LocationMode.PrimaryThenSecondary,則需要指定PrimaryUri和SecondaryUri。

+0

但我需要指定它們在哪裏? – Sameer

+1

new StorageUri(primaryUri,secondryUri) –