You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/storage/queues/queues-v11-samples-dotnet.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ This article shows code samples that use version 11.x of the Azure Queue Storage
19
19
20
20
## Create a Queue Storage client
21
21
22
-
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#create-the-queue-storage-client)
22
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
23
23
24
24
The [`CloudQueueClient`](/dotnet/api/microsoft.azure.storage.queue.cloudqueueclient?view=azure-dotnet-legacy&preserve-view=true) class enables you to retrieve queues stored in Queue Storage. Here's one way to create the service client:
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#create-a-queue)
37
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
38
38
39
39
This example shows how to create a queue:
40
40
@@ -55,7 +55,7 @@ queue.CreateIfNotExists();
55
55
56
56
## Insert a message into a queue
57
57
58
-
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#insert-a-message-into-a-queue)
58
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
59
59
60
60
To insert a message into an existing queue, first create a new [`CloudQueueMessage`](/dotnet/api/microsoft.azure.storage.queue.cloudqueuemessage?view=azure-dotnet-legacy&preserve-view=true). Next, call the [`AddMessage`](/dotnet/api/microsoft.azure.storage.queue.cloudqueue.addmessage?view=azure-dotnet-legacy&preserve-view=true) method. A `CloudQueueMessage` can be created from either a string (in UTF-8 format) or a byte array. The following code example creates a queue (if it doesn't already exist) and inserts the message `Hello, World`:
61
61
@@ -80,7 +80,7 @@ queue.AddMessage(message);
80
80
81
81
## Peek at the next message
82
82
83
-
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#peek-at-the-next-message)
83
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
84
84
85
85
You can peek at the message in the front of a queue without removing it from the queue by calling the [`PeekMessage`](/dotnet/api/microsoft.azure.storage.queue.cloudqueue.peekmessage?view=azure-dotnet-legacy&preserve-view=true) method.
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#change-the-contents-of-a-queued-message)
107
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
108
108
109
109
```csharp
110
110
// Retrieve storage account from connection string.
@@ -127,7 +127,7 @@ queue.UpdateMessage(message,
127
127
128
128
## Dequeue the next message
129
129
130
-
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#dequeue-the-next-message)
130
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
131
131
132
132
Your code dequeues a message from a queue in two steps. When you call [`GetMessage`](/dotnet/api/microsoft.azure.storage.queue.cloudqueue.getmessage?view=azure-dotnet-legacy&preserve-view=true), you get the next message in a queue. A message returned from `GetMessage` becomes invisible to any other code reading messages from this queue. By default, this message stays invisible for 30 seconds. To finish removing the message from the queue, you must also call [`DeleteMessage`](/dotnet/api/microsoft.azure.storage.queue.cloudqueue.deletemessage?view=azure-dotnet-legacy&preserve-view=true). This two-step process of removing a message assures that if your code fails to process a message due to hardware or software failure, another instance of your code can get the same message and try again. Your code calls `DeleteMessage` right after the message has been processed.
## Use the async-await pattern with common Queue Storage APIs
153
153
154
-
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#use-the-async-await-pattern-with-common-queue-storage-apis)
154
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#use-additional-options-for-dequeuing-messages)
185
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
186
186
187
187
The following code example uses the [`GetMessages`](/dotnet/api/microsoft.azure.storage.queue.cloudqueue.getmessages?view=azure-dotnet-legacy&preserve-view=true) method to get 20 messages in one call. Then it processes each message using a `foreach` loop. It also sets the invisibility timeout to five minutes for each message. The timeout starts for all messages at the same time, so after five minutes have passed since the call to `GetMessages`, any messages that haven't been deleted will become visible again.
188
188
@@ -206,7 +206,7 @@ foreach (CloudQueueMessage message in queue.GetMessages(20, TimeSpan.FromMinutes
206
206
207
207
## Get the queue length
208
208
209
-
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#get-the-queue-length)
209
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
210
210
211
211
You can get an estimate of the number of messages in a queue. The [`FetchAttributes`](/dotnet/api/microsoft.azure.storage.queue.cloudqueue.fetchattributes?view=azure-dotnet-legacy&preserve-view=true) method returns queue attributes including the message count. The [`ApproximateMessageCount`](/dotnet/api/microsoft.azure.storage.queue.cloudqueue.approximatemessagecount?view=azure-dotnet-legacy&preserve-view=true) property returns the last value retrieved by the `FetchAttributes` method, without calling Queue Storage.
212
212
@@ -233,7 +233,7 @@ Console.WriteLine("Number of messages in queue: " + cachedMessageCount);
233
233
234
234
## Delete a queue
235
235
236
-
Related article: [Get started with Azure Queue Storage using .NET](storage-dotnet-how-to-use-queues.md#delete-a-queue)
236
+
Related article: [Get started with Azure Queue Storage using .NET](storage-quickstart-queues-dotnet.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
237
237
238
238
To delete a queue and all the messages contained in it, call the [`Delete`](/dotnet/api/microsoft.azure.storage.queue.cloudqueue.delete?view=azure-dotnet-legacy&preserve-view=true) method on the queue object.
Copy file name to clipboardExpand all lines: articles/storage/queues/queues-v2-samples-python.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ This article shows code samples that use version 2 of the Azure Queue Storage cl
19
19
20
20
## Create a queue
21
21
22
-
Related article: [Get started with Azure Queue Storage using Python](storage-python-how-to-use-queue-storage.md#create-a-queue)
22
+
Related article: [Get started with Azure Queue Storage using Python](storage-quickstart-queues-python.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2C)
Related article: [Get started with Azure Queue Storage using Python](storage-python-how-to-use-queue-storage.md#insert-a-message-into-a-queue)
64
+
Related article: [Get started with Azure Queue Storage using Python](storage-quickstart-queues-python.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
65
65
66
66
To insert a message into a queue, use the [`put_message`](/azure/developer/python/sdk/storage/azure-storage-queue/azure.storage.queue.queueservice.queueservice?view=storage-py-v2&preserve-view=true#put-message-queue-name--content--visibility-timeout-none--time-to-live-none--timeout-none-) method to create a new message and add it to the queue.
Related article: [Get started with Azure Queue Storage using Python](storage-python-how-to-use-queue-storage.md#peek-at-messages)
76
+
Related article: [Get started with Azure Queue Storage using Python](storage-quickstart-queues-python.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
77
77
78
78
You can peek at messages without removing them from the queue by calling the [`peek_messages`](/azure/developer/python/sdk/storage/azure-storage-queue/azure.storage.queue.queueservice.queueservice?view=storage-py-v2&preserve-view=true#peek-messages-queue-name--num-messages-none--timeout-none-) method. By default, this method peeks at a single message.
79
79
@@ -86,7 +86,7 @@ for peeked_message in messages:
86
86
87
87
## Change the contents of a queued message
88
88
89
-
Related article: [Get started with Azure Queue Storage using Python](storage-python-how-to-use-queue-storage.md#change-the-contents-of-a-queued-message)
89
+
Related article: [Get started with Azure Queue Storage using Python](storage-quickstart-queues-python.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
90
90
91
91
The following code uses the [`update_message`](/azure/developer/python/sdk/storage/azure-storage-queue/azure.storage.queue.queueservice.queueservice?view=storage-py-v2&preserve-view=true#update-message-queue-name--message-id--pop-receipt--visibility-timeout--content-none--timeout-none-) method to update a message. The visibility timeout is set to 0, meaning the message appears immediately and the content is updated.
92
92
@@ -100,7 +100,7 @@ for message in messages:
100
100
101
101
## Get the queue length
102
102
103
-
Related article: [Get started with Azure Queue Storage using Python](storage-python-how-to-use-queue-storage.md#get-the-queue-length)
103
+
Related article: [Get started with Azure Queue Storage using Python](storage-quickstart-queues-python.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
104
104
105
105
The [`get_queue_metadata`](/azure/developer/python/sdk/storage/azure-storage-queue/azure.storage.queue.queueservice.queueservice?view=storage-py-v2&preserve-view=true#get-queue-metadata-queue-name--timeout-none-) method returns queue properties including `approximate_message_count`.
106
106
@@ -114,7 +114,7 @@ The result is only approximate because messages can be added or removed after th
114
114
115
115
## Dequeue messages
116
116
117
-
Related article: [Get started with Azure Queue Storage using Python](storage-python-how-to-use-queue-storage.md#dequeue-messages)
117
+
Related article: [Get started with Azure Queue Storage using Python](storage-quickstart-queues-python.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
118
118
119
119
When you call [get_messages](/azure/developer/python/sdk/storage/azure-storage-queue/azure.storage.queue.queueservice.queueservice?view=storage-py-v2&preserve-view=true#get-messages-queue-name--num-messages-none--visibility-timeout-none--timeout-none-), you get the next message in the queue by default. A message returned from `get_messages` becomes invisible to any other code reading messages from this queue. By default, this message stays invisible for 30 seconds. To finish removing the message from the queue, you must also call [delete_message](/azure/developer/python/sdk/storage/azure-storage-queue/azure.storage.queue.queueservice.queueservice?view=storage-py-v2&preserve-view=true#delete-message-queue-name--message-id--pop-receipt--timeout-none-).
120
120
@@ -140,7 +140,7 @@ for message in messages:
140
140
141
141
## Delete a queue
142
142
143
-
Related article: [Get started with Azure Queue Storage using Python](storage-python-how-to-use-queue-storage.md#delete-a-queue)
143
+
Related article: [Get started with Azure Queue Storage using Python](storage-quickstart-queues-python.md?tabs=passwordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
144
144
145
145
To delete a queue and all the messages contained in it, call the [`delete_queue`](/azure/developer/python/sdk/storage/azure-storage-queue/azure.storage.queue.queueservice.queueservice?view=storage-py-v2&preserve-view=true#delete-queue-queue-name--fail-not-exist-false--timeout-none-) method.
Copy file name to clipboardExpand all lines: articles/storage/queues/queues-v8-samples-java.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ This article shows code samples that use version 8 of the Azure Queue Storage cl
19
19
20
20
## Create a queue
21
21
22
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#how-to-create-a-queue)
22
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
23
23
24
24
Add the following `import` directives:
25
25
@@ -58,7 +58,7 @@ catch (Exception e)
58
58
59
59
## Add a message to a queue
60
60
61
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#how-to-add-a-message-to-a-queue)
61
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
62
62
63
63
To insert a message into an existing queue, first create a new `CloudQueueMessage`. Next, call the `addMessage` method. A `CloudQueueMessage` can be created from either a string (in UTF-8 format) or a byte array. The following code example creates a queue (if it doesn't exist) and inserts the message `Hello, World`.
64
64
@@ -91,7 +91,7 @@ catch (Exception e)
91
91
92
92
## Peek at the next message
93
93
94
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#how-to-peek-at-the-next-message)
94
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
95
95
96
96
You can peek at the message in the front of a queue without removing it from the queue by calling `peekMessage`.
97
97
@@ -126,7 +126,7 @@ catch (Exception e)
126
126
127
127
## Change the contents of a queued message
128
128
129
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#how-to-change-the-contents-of-a-queued-message)
129
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
130
130
131
131
The following code sample searches through the queue of messages, locates the first message content that matches `Hello, world`, modifies the message content, and exits.
132
132
@@ -210,7 +210,7 @@ catch (Exception e)
210
210
211
211
## Get the queue length
212
212
213
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#how-to-get-the-queue-length)
213
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
214
214
215
215
The `downloadAttributes` method retrieves several values including the number of messages currently in a queue. The count is only approximate because messages can be added or removed after your request. The `getApproximateMessageCount` method returns the last value retrieved by the call to `downloadAttributes`, without calling Queue Storage.
216
216
@@ -245,7 +245,7 @@ catch (Exception e)
245
245
246
246
## Dequeue the next message
247
247
248
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#how-to-dequeue-the-next-message)
248
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
249
249
250
250
Your code dequeues a message from a queue in two steps. When you call `retrieveMessage`, you get the next message in a queue. A message returned from `retrieveMessage` becomes invisible to any other code reading messages from this queue. By default, this message stays invisible for 30 seconds. To finish removing the message from the queue, you must also call `deleteMessage`. If your code fails to process a message, this two-step process ensures that you can get the same message and try again. Your code calls `deleteMessage` right after the message has been processed.
251
251
@@ -280,7 +280,7 @@ catch (Exception e)
280
280
281
281
## Additional options for dequeuing messages
282
282
283
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#additional-options-for-dequeuing-messages)
283
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
284
284
285
285
The following code example uses the `retrieveMessages` method to get 20 messages in one call. Then it processes each message using a `for` loop. It also sets the invisibility timeout to five minutes (300 seconds) for each message. The timeout starts for all messages at the same time. When five minutes have passed since the call to `retrieveMessages`, any messages not deleted becomes visible again.
286
286
@@ -313,7 +313,7 @@ catch (Exception e)
313
313
314
314
## List the queues
315
315
316
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#how-to-list-the-queues)
316
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
317
317
318
318
To obtain a list of the current queues, call the `CloudQueueClient.listQueues()` method, which returns a collection of `CloudQueue` objects.
319
319
@@ -344,7 +344,7 @@ catch (Exception e)
344
344
345
345
## Delete a queue
346
346
347
-
Related article: [Get started with Azure Queue Storage using Java](storage-java-how-to-use-queue-storage.md#how-to-delete-a-queue)
347
+
Related article: [Get started with Azure Queue Storage using Java](storage-quickstart-queues-java.md?tabs=powershell%2Cpasswordless%2Croles-azure-portal%2Cenvironment-variable-windows%2Csign-in-azure-cli)
348
348
349
349
To delete a queue and all the messages contained in it, call the `deleteIfExists` method on the `CloudQueue` object.
0 commit comments