# Complete Guide to Using Azure Storage Queue
This guide provides step-by-step instructions to:
1. Create a **Storage Account** and **Queue** using the Azure Portal.
2. Send and receive messages using Azure Cloud Shell.
---
## Part 1: Creating a Storage Account in Azure Portal
### Step 1: Log in to Azure Portal
1. Navigate to [Azure Portal](https://portal.azure.com/).
2. Sign in with your Azure account.
### Step 2: Create a Resource Group
1. In the **Search bar**, type `Resource Groups` and select the result.
2. Click **+ Create**.
3. Fill in the details:
- **Subscription**: Select your subscription.
- **Resource group**: Enter a name (e.g., `StorageQueueDemoRG`).
- **Region**: Select a region (e.g., `East US`).
4. Click **Review + Create**, then **Create**.
### Step 3: Create a Storage Account
1. In the **Search bar**, type `Storage Accounts` and select the result.
2. Click **+ Create**.
3. Fill in the details:
- **Subscription**: Select your subscription.
- **Resource Group**: Select `StorageQueueDemoRG`.
- **Storage Account Name**: Enter a unique name (e.g., `ordersstoragedemo`).
- **Region**: Select a region (e.g., `East US`).
- **Performance**: Standard.
- **Replication**: Locally-redundant storage (LRS).
4. Click **Review + Create**, then **Create**.
---
## Part 2: Creating a Queue in Azure Portal
### Step 1: Navigate to the Storage Account
1. In the **Search bar**, type `Storage Accounts` and select the storage account you created (e.g., `ordersstoragedemo`).
### Step 2: Create a Queue
1. In the storage account, select **Queues** from the left-hand menu.
2. Click **+ Queue**.
3. Enter the **Queue Name** (e.g., `ordersqueue`) and click **OK**.
---
## Part 3: Sending and Receiving Messages via Azure Cloud Shell
### Step 1: Access Azure Cloud Shell
1. In the Azure Portal, click the **Cloud Shell** icon in the top-right corner.
2. Select **Bash** or **PowerShell** (this guide uses Bash).
### Step 2: Retrieve the Connection String
1. Run the following command to retrieve the connection string:
```bash
connectionString=$(az storage account show-connection-string --name ordersstoragedemo --query connectionString -o tsv)
```
2. Verify the connection string:
```bash
echo $connectionString
```
### Step 3: Send Messages to the Queue
1. Send the first message:
```bash
az storage message put --queue-name ordersqueue --content "Order ID: 201, Product: Laptop, Quantity: 1" --connection-string $connectionString
```
2. Send the second message:
```bash
az storage message put --queue-name ordersqueue --content "Order ID: 202, Product: Phone, Quantity: 2" --connection-string $connectionString
```
### Step 4: Receive Messages from the Queue
1. Peek at the first message:
```bash
az storage message peek --queue-name ordersqueue --connection-string $connectionString
```
2. Retrieve and delete the first message:
```bash
az storage message get --queue-name ordersqueue --connection-string $connectionString --delete
```
---
## Additional Steps: Clean Up Resources (Optional)
1. To delete the resource group and associated resources:
```bash
az group delete --name StorageQueueDemoRG --no-wait --yes
```
---
## Summary
You have successfully:
- Created a **Storage Account** and **Queue** in Azure Portal.
- Sent and received messages using Azure Cloud Shell.
---
## Additional Resources
- [Azure Storage Queue Documentation](https://learn.microsoft.com/en-us/azure/storage/queues/)
- [Azure CLI Documentation](https://learn.microsoft.com/en-us/cli/azure/)
```