本文整理汇总了C#中Microsoft.WindowsAzure.Storage.CloudStorageAccount.CreateCloudQueueClient方法的典型用法代码示例。如果您正苦于以下问题:C# CloudStorageAccount.CreateCloudQueueClient方法的具体用法?C# CloudStorageAccount.CreateCloudQueueClient怎么用?C# CloudStorageAccount.CreateCloudQueueClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.WindowsAzure.Storage.CloudStorageAccount
的用法示例。
在下文中一共展示了CloudStorageAccount.CreateCloudQueueClient方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
/// <summary>
/// The main entry point.
/// </summary>
/// <param name="args">
/// The command line arguments. Not used.
/// </param>
private static void Main(string[] args)
{
var credentials = new StorageCredentials("rwwa", "vyMfaSPxURHXZaIhhFJQRg5ZLEN6qDj4yU78r3oeOH+pZzdcf4S86QvGAsB6L8JaPti9qJbB929hy1Y9hipFmw==");
// Retrieve storage account from connection string.
var storageAccount = new CloudStorageAccount(credentials, true);
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
// Retrieve a reference to a queue
CloudQueue queue = queueClient.GetQueueReference("dataqueue");
queue.CreateIfNotExists();
Console.WriteLine("Up and listening to the queue.");
while (true)
{
CloudQueueMessage message;
do
{
message = queue.GetMessage();
if (message != null)
{
Console.WriteLine("Received Message for BLOB " + message.AsString);
var blobUrl = message.AsString;
var blockBlob = new CloudBlockBlob(new Uri(blobUrl), credentials);
if (blockBlob.Exists())
{
// TODO: download and process BLOB
/*using (var fileStream = System.IO.File.OpenWrite(@"path\myfile"))
{
blockBlob.DownloadToStream(fileStream);
}*/
blockBlob.Delete();
}
queue.DeleteMessage(message);
Console.WriteLine("BLOB " + message.AsString + " and queue message deleted.");
}
}
while (message != null);
Thread.Sleep(TimeSpan.FromSeconds(5));
}
}
示例2: Main
/// <summary>
/// The main entry point.
/// </summary>
/// <param name="args">
/// The command line arguments. Not used.
/// </param>
private static void Main(string[] args)
{
var credentials = new StorageCredentials("[Enter your account name]", "[Enter your account key]");
// Retrieve storage account from connection string.
var storageAccount = new CloudStorageAccount(credentials, true);
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
// Retrieve a reference to a queue
CloudQueue queue = queueClient.GetQueueReference("dataqueue");
Console.WriteLine("Up and listening to the queue.");
while (true)
{
CloudQueueMessage message;
do
{
message = queue.GetMessage();
if (message != null)
{
Console.WriteLine("Received Message for BLOB " + message.AsString);
var blobUrl = message.AsString;
var blockBlob = new CloudBlockBlob(new Uri(blobUrl), credentials);
if (blockBlob.Exists())
{
// TODO: download and process BLOB
/*using (var fileStream = System.IO.File.OpenWrite(@"path\myfile"))
{
blockBlob.DownloadToStream(fileStream);
}*/
blockBlob.Delete();
}
queue.DeleteMessage(message);
Console.WriteLine("BLOB " + message.AsString + " and queue message deleted.");
}
}
while (message != null);
Thread.Sleep(TimeSpan.FromSeconds(5));
}
}
示例3: Run
public override void Run()
{
storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
cmdQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("krawlercmd");
urlQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("krawlerurl");
errorQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("krawlererror");
lastTenUrlQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("lasttenurlcrawled");
index = storageAccount.CreateCloudTableClient().GetTableReference("krawlerindex");
visisted = new HashSet<string>();
cmdQueue.CreateIfNotExists();
urlQueue.CreateIfNotExists();
errorQueue.CreateIfNotExists();
lastTenUrlQueue.CreateIfNotExists();
// This is a sample worker implementation. Replace with your logic.
Trace.TraceInformation("WorkerRole entry point called", "Information");
Crawler crawler = new Crawler();
//cmdQueue.Clear();
//cmdQueue.AddMessage(new CloudQueueMessage("stop"));
while (true)
{
Thread.Sleep(500);
Trace.TraceInformation("Working", "Information");
CloudQueueMessage cmd = cmdQueue.PeekMessage();
if (cmd == null || cmd.AsString == "stop")
{
continue;
}
else if (cmd.AsString == "start")
{
CloudQueueMessage url = urlQueue.GetMessage();
if (!visisted.Contains(url.AsString))
{
crawler.Crawl(url.AsString);
visisted.Add(url.AsString);
}
urlQueue.DeleteMessage(url);
}
else if (cmd.AsString == "load" && urlQueue.PeekMessage() == null)
{
crawler.LoadQueue("http://www.cnn.com");
}
else
{
continue;
}
}
}
示例4: Crawler
public Crawler()
{
storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
urlQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("krawlerurl");
cmdQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("krawlercmd");
index = storageAccount.CreateCloudTableClient().GetTableReference("krawlerindex");
errorQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("krawlererror");
lastTenUrlQueue = storageAccount.CreateCloudQueueClient().GetQueueReference("lasttenurlcrawled");
crawlStatTable = storageAccount.CreateCloudTableClient().GetTableReference("krawlerstattable");
disallowedPaths = new List<string>();
visited = new HashSet<string>();
crawlStatTable.CreateIfNotExists();
crawlCounter = (NumberOfUrlCrawled() != 0) ? NumberOfUrlCrawled() : 0;
}
示例5: BlobManager
public BlobManager(string conStr)
{
//RoleEnvironment.GetConfigurationSettingValue("UploadCon")
Storage = CloudStorageAccount.Parse(conStr);
BlobClient = Storage.CreateCloudBlobClient();
QueueClient = Storage.CreateCloudQueueClient();
}
示例6: Run
public static void Run(string connectionString, bool disableLogging)
{
_connectionString = connectionString;
_storageAccount = CloudStorageAccount.Parse(connectionString);
_queueClient = _storageAccount.CreateCloudQueueClient();
try
{
TimeSpan azureSDKTime = RunAzureSDKTest();
TimeSpan webJobsSDKTime = RunWebJobsSDKTest(disableLogging);
// Convert to ulong because the measurment block does not support other data type
ulong perfRatio = (ulong)((webJobsSDKTime.TotalMilliseconds / azureSDKTime.TotalMilliseconds) * 100);
Console.WriteLine("--- Results ---");
Console.WriteLine("Azure SDK: {0} ms: ", azureSDKTime.TotalMilliseconds);
Console.WriteLine("WebJobs SDK: {0} ms: ", webJobsSDKTime.TotalMilliseconds);
Console.WriteLine("Perf ratio (x100, long): {0}", perfRatio);
MeasurementBlock.Mark(
perfRatio,
(disableLogging ? QueueNoLoggingOverheadMetric : QueueLoggingOverheadMetric) + ";Ratio;Percent");
}
finally
{
Cleanup();
}
}
示例7: configureQueue
protected virtual void configureQueue(CloudStorageAccount storageAccount)
{
// Create the queue client
this.queueClient = storageAccount.CreateCloudQueueClient();
this.queue = createQueue(this.queueClient, this.queueName);
}
示例8: MakeQueue
private static CloudQueue MakeQueue(CloudStorageAccount account)
{
var client = account.CreateCloudQueueClient();
client.RetryPolicy = new ExponentialRetry(new TimeSpan(0, 0, 0, 2), 10);
return client.GetQueueReference(QueueName);
}
示例9: AzureStorageQueuesTransport
/// <summary>
/// Constructs the transport
/// </summary>
public AzureStorageQueuesTransport(CloudStorageAccount storageAccount, string inputQueueName)
{
if (storageAccount == null) throw new ArgumentNullException("storageAccount");
if (inputQueueName == null) throw new ArgumentNullException("inputQueueName");
_inputQueueName = inputQueueName.ToLowerInvariant();
_queueClient = storageAccount.CreateCloudQueueClient();
}
示例10: Initialize
public static void Initialize(string storageConnectionString, string ocrQueueName, string emailQueueName)
{
storageAccount = CloudStorageAccount.Parse(storageConnectionString);
queueClient = storageAccount.CreateCloudQueueClient();
ocrQueue = InitializeQueue(ocrQueueName);
emailQueue = InitializeQueue(emailQueueName);
}
示例11: QueueHelper
// Constructor - pass in a storage connection string.
public QueueHelper(string connectionString)
{
Account = CloudStorageAccount.Parse(connectionString);
QueueClient = Account.CreateCloudQueueClient();
IRetryPolicy linearRetryPolicy = new LinearRetry(TimeSpan.Zero, 4);
QueueClient.RetryPolicy = linearRetryPolicy;
}
示例12: StorageHelper
static StorageHelper()
{
if (!string.IsNullOrEmpty(SimpleSettings.StorageConnectionString))
{
StorageAccount = CloudStorageAccount.Parse(SimpleSettings.StorageConnectionString);
BlobClient = StorageAccount.CreateCloudBlobClient();
QueueClient = StorageAccount.CreateCloudQueueClient();
}
}
示例13: QueueRepository
public QueueRepository()
{
try
{
_storageAccount = CloudStorageAccount.Parse(ConfigReader<string>.GetSetting("EarthOnlineStorage"));
_blobClient = _storageAccount.CreateCloudBlobClient();
_queueClient = _storageAccount.CreateCloudQueueClient();
}
catch (Exception) { }//fail silently for developers without valid storage settings
}
示例14: CreateQueues
private void CreateQueues(CloudStorageAccount storageAccount)
{
var mailQueueName = CloudConfigurationManager.GetSetting("MailQueue.Name");
var queueClient = storageAccount.CreateCloudQueueClient();
var queue = queueClient.GetQueueReference(mailQueueName);
queue.CreateIfNotExists();
}
示例15: azureStorageHelper
public azureStorageHelper(string acountName, string accountKey)
{
sCredentials = new StorageCredentials(acountName, accountKey);
storageAccount = new CloudStorageAccount(sCredentials, true);
queueClient = storageAccount.CreateCloudQueueClient();
blobClient = storageAccount.CreateCloudBlobClient();
permisions = new BlobContainerPermissions();
permisions.PublicAccess = BlobContainerPublicAccessType.Container;
}