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
Azure Queue storage provides cloud messaging between application components. In designing applications for scale, application components are often decoupled, so that they can scale independently. Queue storage delivers asynchronous messaging for communication between application components, whether they are running in the cloud, on the desktop, on an on-premises server, or on a mobile device. Queue storage also supports managing asynchronous tasks and building process work flows.
22
+
Azure Queue storage provides cloud messaging between application components. In designing applications for scale, application components are often decoupled so they can scale independently. Queue storage delivers asynchronous messaging between application components, whether they are running in the cloud, on the desktop, on an on-premises server, or on a mobile device. Queue storage also supports managing asynchronous tasks and building process work flows.
23
23
24
24
### About this tutorial
25
25
@@ -60,18 +60,38 @@ You can use the Azure Storage client libraries in any type of .NET application,
60
60
61
61
### Use NuGet to install the required packages
62
62
63
+
# [\.NET v12](#tab/dotnet)
64
+
65
+
You need to reference the following four packages in your project to complete this tutorial:
66
+
67
+
-[Azure Storage Common Client Library for .NET](https://www.nuget.org/packages/Azure.Storage.Common/): This package provides programmatic access to data resources in your storage account.
68
+
-[Azure Storage Queue Library for .NET](https://www.nuget.org/packages/Azure.Storage.Queues/): This client library enables working with the Microsoft Azure Storage Queue service for storing messages that may be accessed by a client.
69
+
-[Azure Core library for .NET](https://www.nuget.org/packages/Azure.Core/): This package provides a class for parsing a connection string in a configuration file, regardless of where your application is running.
70
+
-[Configuration Manager library for .NET](https://www.nuget.org/packages/System.Configuration.ConfigurationManager/): This package provides a class for retrieving the connection string from a configuration file.
71
+
72
+
You can use NuGet to obtain these packages. Follow these steps:
73
+
74
+
1. Right-click your project in **Solution Explorer**, and choose **Manage NuGet Packages**.
75
+
1. Select **Browse**
76
+
1. Search online for "Azure.Storage.Queues", and select **Install** to install the Storage client library and its dependencies. This will also install the Azure.Storage.Common and Azure.Core libraries, which are dependencies of the queue library.
77
+
1. Search online for "System.Configuration.ConfigurationManager", and select **Install** to install the Configuration Manager.
78
+
79
+
# [\.NET v11](#tab/dotnetv11)
80
+
63
81
You need to reference the following three packages in your project to complete this tutorial:
64
82
65
-
*[Microsoft Azure Storage Common Client Library for .NET](https://www.nuget.org/packages/Microsoft.Azure.Storage.Common/): This package provides programmatic access to data resources in your storage account.
66
-
*[Microsoft Azure Storage Queue Library for .NET](https://www.nuget.org/packages/Microsoft.Azure.Storage.Queue/): This client library enables working with the Microsoft Azure Storage Queue service for storing messages that may be accessed by a client.
67
-
*[Microsoft Azure Configuration Manager library for .NET](https://www.nuget.org/packages/Microsoft.Azure.ConfigurationManager/): This package provides a class for parsing a connection string in a configuration file, regardless of where your application is running.
83
+
-[Microsoft Azure Storage Common Client Library for .NET](https://www.nuget.org/packages/Microsoft.Azure.Storage.Common/): This package provides programmatic access to data resources in your storage account.
84
+
-[Microsoft Azure Storage Queue Library for .NET](https://www.nuget.org/packages/Microsoft.Azure.Storage.Queue/): This client library enables working with the Microsoft Azure Storage Queue service for storing messages that may be accessed by a client.
85
+
-[Microsoft Azure Configuration Manager library for .NET](https://www.nuget.org/packages/Microsoft.Azure.ConfigurationManager/): This package provides a class for parsing a connection string in a configuration file, regardless of where your application is running.
68
86
69
87
You can use NuGet to obtain these packages. Follow these steps:
70
88
71
89
1. Right-click your project in **Solution Explorer**, and choose **Manage NuGet Packages**.
72
-
2. Select **Browse**
73
-
3. Search online for "Microsoft.Azure.Storage.Queue", and select **Install** to install the Storage client library and its dependencies. This will also install the Microsoft.Azure.Storage.Common library, which is a dependency of the queue library.
74
-
4. Search online for "Microsoft.Azure.ConfigurationManager", and select **Install** to install the Azure Configuration Manager.
90
+
1. Select **Browse**
91
+
1. Search online for "Microsoft.Azure.Storage.Queue", and select **Install** to install the Storage client library and its dependencies. This will also install the Microsoft.Azure.Storage.Common library, which is a dependency of the queue library.
92
+
1. Search online for "Microsoft.Azure.ConfigurationManager", and select **Install** to install the Azure Configuration Manager.
93
+
94
+
---
75
95
76
96
> [!NOTE]
77
97
> The Storage client libraries packages are also included in the [Azure SDK for .NET](https://azure.microsoft.com/downloads/). However, we recommend that you also install the Storage client libraries from NuGet to ensure that you always have the latest versions.
@@ -82,102 +102,142 @@ You can use NuGet to obtain these packages. Follow these steps:
82
102
83
103
You have two environment options for running the examples in this guide:
84
104
85
-
* You can run your code against an Azure Storage account in the cloud.
86
-
* You can run your code against the Azure storage emulator. The storage emulator is a local environment that emulates an Azure Storage account in the cloud. The emulator is a free option for testing and debugging your code while your application is under development. The emulator uses a well-known account and key. For more information, see [Use the Azure storage emulator for development and testing](../common/storage-use-emulator.md).
87
-
88
-
If you are targeting a storage account in the cloud, copy the primary access key for your storage account from the Azure portal. For more information, see [Manage storage account access keys](../common/storage-account-keys-manage.md).
105
+
- You can run your code against an Azure Storage account in the cloud.
106
+
- You can run your code against the Azurite storage emulator. Azurite is a local environment that emulates an Azure Storage account in the cloud. Azurite is a free option for testing and debugging your code while your application is under development. The emulator uses a well-known account and key. For more information, see [Use the Azurite emulator for local Azure Storage development and testing](../common/storage-use-azurite.md).
89
107
90
108
> [!NOTE]
91
109
> You can target the storage emulator to avoid incurring any costs associated with Azure Storage. However, if you do choose to target an Azure storage account in the cloud, costs for performing this tutorial will be negligible.
92
110
93
-
### Configure your storage connection string
111
+
## Configure your storage connection string
112
+
113
+
The Azure Storage client libraries for .NET support using a storage connection string to configure endpoints and credentials for accessing storage services. For more information, see [Manage storage account access keys](../common/storage-account-keys-manage.md).
114
+
115
+
### Copy your credentials from the Azure portal
116
+
117
+
The sample code needs to authorize access to your storage account. To authorize, you provide the application with your storage account credentials in the form of a connection string. To view your storage account credentials:
118
+
119
+
1. Navigate to the [Azure portal](https://portal.azure.com).
120
+
2. Locate your storage account.
121
+
3. In the **Settings** section of the storage account overview, select **Access keys**. Your account access keys appear, as well as the complete connection string for each key.
122
+
4. Find the **Connection string** value under **key1**, and click the **Copy** button to copy the connection string. You will add the connection string value to an environment variable in the next step.
94
123
95
-
The Azure Storage client libraries for .NET support using a storage connection string to configure endpoints and credentials for accessing storage services. The best way to maintain your storage connectionstring is in a configuration file.
124
+

96
125
97
126
For more information about connection strings, see [Configure a connection string to Azure Storage](../common/storage-configure-connection-string.md).
98
127
99
128
> [!NOTE]
100
129
> Your storage account key is similar to the root password for your storage account. Always be careful to protect your storage account key. Avoid distributing it to other users, hard-coding it, or saving it in a plain-text file that is accessible to others. Regenerate your key by using the Azure portal if you believe it may have been compromised.
101
130
102
-
To configure your connection string, open the **app.config** file from Solution Explorer in Visual Studio. Add the contents of the **\<appSettings\>** element shown below. Replace *account-name* with the name of your storage account, and *account-key* with your account access key:
131
+
The best way to maintain your storage connection string is in a configuration file. To configure your connection string, open the **app.config** file from Solution Explorer in Visual Studio. Add the contents of the **\<appSettings\>** element shown below. Replace *connection-string* with the value you copied from your storage account in the portal:
To target the storage emulator, you can use a shortcut that maps to the well-known account name and key. In that case, your connection string setting is:
150
+
To target the Azurite storage emulator, you can use a shortcut that maps to the well-known account name and key. In that case, your connection string setting is:
Add the following `using` directives to the top of the `Program.cs` file:
130
159
160
+
# [\.NET v12](#tab/dotnet)
161
+
131
162
```csharp
163
+
usingSystem;
164
+
usingSystem.Configuration; // Namespace for ConfigurationManager
165
+
usingAzure.Storage.Queues; // Namespace for Queue storage types
166
+
usingAzure.Storage.Queues.Models; // Namespace for Queue models
167
+
```
168
+
169
+
# [\.NET v11](#tab/dotnetv11)
170
+
171
+
```csharp
172
+
usingSystem;
132
173
usingMicrosoft.Azure; // Namespace for CloudConfigurationManager
133
174
usingMicrosoft.Azure.Storage; // Namespace for CloudStorageAccount
134
175
usingMicrosoft.Azure.Storage.Queue; // Namespace for Queue storage types
135
176
```
136
177
137
-
### Copy your credentials from the Azure portal
178
+
---
138
179
139
-
The sample code needs to authorize access to your storage account. To authorize, you provide the application with your storage account credentials in the form of a connection string. To view your storage account credentials:
180
+
### Create the Queue service client
140
181
141
-
1. Navigate to the [Azure portal](https://portal.azure.com).
142
-
2. Locate your storage account.
143
-
3. In the **Settings** section of the storage account overview, select **Access keys**. Your account access keys appear, as well as the complete connection string for each key.
144
-
4. Find the **Connection string** value under **key1**, and click the **Copy** button to copy the connection string. You will add the connection string value to an environment variable in the next step.
182
+
# [\.NET v12](#tab/dotnet)
145
183
146
-

184
+
The [QueueClient](/dotnet/api/azure.storage.queues.queueclient) class enables you to retrieve queues stored in Queue storage. Here's one way to create the service client:
The [CloudQueueClient](https://docs.microsoft.com/dotnet/api/microsoft.azure.storage.queue.cloudqueueclient?view=azure-dotnet) class enables you to retrieve queues stored in Queue storage. Here's one way to create the service client:
200
+
The [CloudQueueClient](/dotnet/api/microsoft.azure.storage.queue.cloudqueueclient?view=azure-dotnet-legacy) class enables you to retrieve queues stored in Queue storage. Here's one way to create the service client:
155
201
156
202
```csharp
203
+
// Retrieve storage account from connection string
To insert a message into an existing queue, first create a new [CloudQueueMessage](https://docs.microsoft.com/dotnet/api/microsoft.azure.storage.queue.cloudqueuemessage?view=azure-dotnet). Next, call the [AddMessage](https://docs.microsoft.com/dotnet/api/microsoft.azure.storage.queue.cloudqueue.addmessage?view=azure-dotnet) method. A
0 commit comments