WEB开发网
开发学院服务器云计算 云存储:使用 Windows Azure Storage 增强应用程序... 阅读

云存储:使用 Windows Azure Storage 增强应用程序的引擎

 2010-03-26 00:00:00 来源:WEB开发网   
核心提示: 图 1 创建消息并将其提交给 Windows Azure QueuestringaccountName;stringaccountSharedKey;stringqueueBaseUri;stringStorageCredentialsAccountAndKeycredentials;if(Ro

图 1 创建消息并将其提交给 Windows Azure Queue

string accountName; 
string accountSharedKey; 
string queueBaseUri; 
string StorageCredentialsAccountAndKey credentials; 
 
if (RoleEnvironment.IsAvailable) 
{ 
// We are running in a cloud - INCLUDING LOCAL! 
 accountName = 
 RoleEnvironment.GetConfigurationSettingValue("AccountName"); 
 accountSharedKey =  
 RoleEnvironment.GetConfigurationSettingValue("AccountSharedKey"); 
 queueBaseUri = RoleEnvironment.GetConfigurationSettingValue 
 ("QueueStorageEndpoint"); 
} 
else 
{ 
 accountName = ConfigurationManager.AppSettings["AccountName"]; 
 accountSharedKey = 
 ConfigurationManager.AppSettings["AccountSharedKey"]; 
 queueBaseUri = 
 ConfigurationManager.AppSettings["QueueStorageEndpoint"]; 
} 
credentials = 
new StorageCredentialsAccountAndKey(accountName, accountSharedKey); 
CloudQueueClient client = 
new CloudQueueClient(queueBaseUri, credentials); 
CloudQueue queue = client.GetQueueReference(queueName); 
CloudQueueMessage m = new CloudQueueMessage( 
 /* string or byte[] representing message to enqueue */); 
Queue.AddMessage(m);

对于本文中的其他示例,我们使用了可以简化此过程的一些包装类(位于 Hollywood Hackers 的 CodePlex 站点中,网址为:hollywoodhackers.codeplex.com/SourceControl/ListDownloadableCommits.aspx)。

上一页  1 2 3 4 5 6 7 8  下一页

Tags:存储 使用 Windows

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接