1919using Microsoft . WindowsAzure . Storage . Queue ;
2020using System ;
2121using System . Collections . Generic ;
22+ using System . Linq ;
2223using System . Threading . Tasks ;
2324using Microsoft . WindowsAzure . Storage . Queue . Protocol ;
2425using Microsoft . WindowsAzure . Storage . RetryPolicies ;
@@ -124,7 +125,17 @@ private static async Task ListQueuesSample(CloudQueueClient cloudQueueClient)
124125 Console . WriteLine ( "List of queues in the storage account:" ) ;
125126
126127 // List the queues for this storage account
127- IEnumerable < CloudQueue > cloudQueueList = cloudQueueClient . ListQueues ( ) ;
128+ QueueContinuationToken token = null ;
129+ List < CloudQueue > cloudQueueList = new List < CloudQueue > ( ) ;
130+
131+ do
132+ {
133+ QueueResultSegment segment = await cloudQueueClient . ListQueuesSegmentedAsync ( baseQueueName , token ) ;
134+ token = segment . ContinuationToken ;
135+ cloudQueueList . AddRange ( segment . Results ) ;
136+ }
137+ while ( token != null ) ;
138+
128139 try
129140 {
130141 foreach ( CloudQueue cloudQ in cloudQueueList )
@@ -200,10 +211,9 @@ private static async Task CorsSample(CloudQueueClient queueClient)
200211 ServiceProperties originalProperties = await queueClient . GetServicePropertiesAsync ( ) ;
201212 try
202213 {
203- // Set CORS rules
204- Console . WriteLine ( "Set CORS rules " ) ;
214+ // Add CORS rule
215+ Console . WriteLine ( "Add CORS rule " ) ;
205216
206- CorsProperties cors = new CorsProperties ( ) ;
207217 CorsRule corsRule = new CorsRule
208218 {
209219 AllowedHeaders = new List < string > { "*" } ,
@@ -213,9 +223,8 @@ private static async Task CorsSample(CloudQueueClient queueClient)
213223 MaxAgeInSeconds = 3600
214224 } ;
215225
216- cors . CorsRules . Add ( corsRule ) ;
217226 ServiceProperties serviceProperties = await queueClient . GetServicePropertiesAsync ( ) ;
218- serviceProperties . Cors = cors ;
227+ serviceProperties . Cors . CorsRules . Add ( corsRule ) ;
219228 await queueClient . SetServicePropertiesAsync ( serviceProperties ) ;
220229 }
221230 finally
@@ -245,6 +254,10 @@ private static async Task ServiceStatsSample(CloudQueueClient queueClient)
245254 Console . WriteLine ( " Last sync time: {0}" , stats . GeoReplication . LastSyncTime ) ;
246255 Console . WriteLine ( " Status: {0}" , stats . GeoReplication . Status ) ;
247256 }
257+ catch ( StorageException )
258+ {
259+ // only works on RA-GRS (Read Access – Geo Redundant Storage)
260+ }
248261 finally
249262 {
250263 // Restore original value
@@ -263,36 +276,16 @@ private static async Task QueueMetadataSample(CloudQueueClient cloudQueueClient)
263276 {
264277 // Create the queue name -- use a guid in the name so it's unique.
265278 string queueName = "demotest-" + Guid . NewGuid ( ) ;
266-
267- // Create the queue with this name.
268- Console . WriteLine ( "Creating queue with name {0}" , queueName ) ;
269279 CloudQueue queue = cloudQueueClient . GetQueueReference ( queueName ) ;
270- try
271- {
272- await queue . CreateIfNotExistsAsync ( ) ;
273- Console . WriteLine ( " Queue created successfully." ) ;
274- }
275- catch ( StorageException exStorage )
276- {
277- Common . WriteException ( exStorage ) ;
278- Console . WriteLine (
279- "Please make sure your storage account is specified correctly in the app.config - then restart the sample." ) ;
280- Console . WriteLine ( "Press any key to exit" ) ;
281- Console . ReadLine ( ) ;
282- throw ;
283- }
284- catch ( Exception ex )
285- {
286- Console . WriteLine ( " Exception thrown creating queue." ) ;
287- Common . WriteException ( ex ) ;
288- throw ;
289- }
290280
291281 // Set queue metadata
292282 Console . WriteLine ( "Set queue metadata" ) ;
293283 queue . Metadata . Add ( "key1" , "value1" ) ;
294284 queue . Metadata . Add ( "key2" , "value2" ) ;
295- await queue . SetMetadataAsync ( ) ;
285+
286+ // Create the queue with this name.
287+ Console . WriteLine ( "Creating queue with name {0}" , queueName ) ;
288+ await queue . CreateIfNotExistsAsync ( ) ;
296289
297290 // Fetch queue attributes
298291 // in this case this call is not need but is included for demo purposes
0 commit comments