@azure/storage-queue (TypeScript/JavaScript)
使用 TypeScript 操作 Azure Queue Storage
使用 Azure Queue Storage SDK 將訊息佇列功能整合到您的應用程式中。此技能提供就緒可用的程式碼範本,用於在 Azure 佇列中傳送、接收和管理訊息。
下載技能 ZIP
在 Claude 中上傳
前往 設定 → 功能 → 技能 → 上傳技能
開啟並開始使用
測試它
正在使用「@azure/storage-queue (TypeScript/JavaScript)」。 傳送訊息至佇列
預期結果:
程式碼範例展示使用 QueueServiceClient 和 DefaultAzureCredential 進行適當的驗證設定後呼叫 sendMessage
正在使用「@azure/storage-queue (TypeScript/JavaScript)」。 接收訊息
預期結果:
工作程式模式程式碼,展示 receiveMessages 並在使用 popReceipt 成功處理後適當刪除
正在使用「@azure/storage-queue (TypeScript/JavaScript)」。 錯誤處理
預期結果:
針對常見 HTTP 狀態碼(404、400、403、409)進行 RestError 處理的 try-catch 區塊
安全審計
安全This is a prompt-only documentation skill containing no executable code. The skill provides documentation and code examples for the @azure/storage-queue SDK. Static analysis scanned 0 files (0 lines) and detected 0 security issues. No suspicious patterns or risk factors were identified. The skill is safe for publication.
品質評分
你能建構什麼
建立訊息處理背景服務
建立背景服務,從 Azure 佇列接收訊息、處理它們,並在完成後刪除。
實作任務排程
使用佇列在多個工作程式之間分配任務,並為長時間運作的作業設定可調整的可見性逾時時間。
解耦應用程式元件
透過 Azure Queue Storage 傳送和接收訊息,實現微服務之間的非同步通訊。
試試這些提示
Show me how to send a message to an Azure Queue Storage queue using the @azure/storage-queue SDK with DefaultAzureCredential.
Write a code example for receiving up to 10 messages from an Azure queue, processing each message, and deleting them after successful processing.
Implement poison message handling for Azure Queue Storage. Move messages that have failed processing more than 5 times to a dead-letter queue.
Show how to implement visibility timeout extension for long-running message processing tasks in Azure Queue Storage.
最佳實務
- 使用 DefaultAzureCredential 而非連線字串或帳戶金鑰,以提升安全性
- 務必在成功處理後刪除訊息,防止重複處理
- 根據預期的訊息處理時間設定適當的可見性逾時時間
避免
- 切勿在原始碼中硬式編碼儲存體帳戶憑證 - 請使用環境變數或受控身分識別
- 切勿忘記處理毒化訊息 - 它們會無限阻擋佇列處理
- 對於長時間運作的作業,切勿將可見性逾時設定得太短 - 訊息會在處理完成前再次變為可見