當前位置: 首頁>>代碼示例>>C#>>正文


C# CloudStorageAccount.CreateCloudQueueClient方法代碼示例

本文整理匯總了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));
            }
        }
開發者ID:rolandkru,項目名稱:rwwa-presentation,代碼行數:51,代碼來源:Program.cs

示例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));
            }
        }
開發者ID:rolandkru,項目名稱:RWWA-Article1,代碼行數:50,代碼來源:Program.cs

示例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;
                }
            }
        }
開發者ID:ngokchau,項目名稱:pa4,代碼行數:53,代碼來源:WorkerRole.cs

示例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;
        }
開發者ID:ngokchau,項目名稱:pa4,代碼行數:15,代碼來源:Crawler.cs

示例5: BlobManager

 public BlobManager(string conStr)
 {
     //RoleEnvironment.GetConfigurationSettingValue("UploadCon")
     Storage = CloudStorageAccount.Parse(conStr);
     BlobClient = Storage.CreateCloudBlobClient();
     QueueClient = Storage.CreateCloudQueueClient();
 }
開發者ID:peacecwz,項目名稱:AAYazOkuluCloudService,代碼行數:7,代碼來源:BlobManager.cs

示例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();
            }
        }
開發者ID:rafaelmtz,項目名稱:azure-webjobs-sdk,代碼行數:29,代碼來源:QueueOverheadPerfTest.cs

示例7: configureQueue

        protected virtual void configureQueue(CloudStorageAccount storageAccount)
        {
            // Create the queue client
            this.queueClient = storageAccount.CreateCloudQueueClient();

            this.queue = createQueue(this.queueClient, this.queueName);
        }
開發者ID:NewMediaCenterMoscow,項目名稱:UniSocial3,代碼行數:7,代碼來源:BaseMessageWorker.cs

示例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);
		}
開發者ID:random-username,項目名稱:WindowsAzure.Unity.Demo,代碼行數:7,代碼來源:QueueMessageSource.cs

示例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();
        }
開發者ID:geffzhang,項目名稱:Rebus,代碼行數:11,代碼來源:AzureStorageQueuesTransport.cs

示例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);
        }
開發者ID:melicamp,項目名稱:azure-cloud-ocr,代碼行數:8,代碼來源:AzureQueues.cs

示例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;
        }
開發者ID:ramonyoung7,項目名稱:Azure-Storage-Samples,代碼行數:9,代碼來源:QueueHelper.cs

示例12: StorageHelper

 static StorageHelper()
 {
     if (!string.IsNullOrEmpty(SimpleSettings.StorageConnectionString))
     {
         StorageAccount = CloudStorageAccount.Parse(SimpleSettings.StorageConnectionString);
         BlobClient = StorageAccount.CreateCloudBlobClient();
         QueueClient = StorageAccount.CreateCloudQueueClient();
     }
 }
開發者ID:davidlai-msft,項目名稱:SimpleWAWS,代碼行數:9,代碼來源:StorageHelper.cs

示例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
 }
開發者ID:faorg,項目名稱:wwt-website,代碼行數:10,代碼來源:QueueRepository.cs

示例14: CreateQueues

        private void CreateQueues(CloudStorageAccount storageAccount)
        {
            var mailQueueName = CloudConfigurationManager.GetSetting("MailQueue.Name");

            var queueClient = storageAccount.CreateCloudQueueClient();

            var queue = queueClient.GetQueueReference(mailQueueName);

            queue.CreateIfNotExists();
        }
開發者ID:jladuval,項目名稱:MyPlace,代碼行數:10,代碼來源:AzureStorage.cs

示例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;
        }
開發者ID:dkouznet3,項目名稱:ScaleDemo,代碼行數:10,代碼來源:Storage.cs


注:本文中的Microsoft.WindowsAzure.Storage.CloudStorageAccount.CreateCloudQueueClient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。