如何通过PowerShell作业将消息发布到存储队列中 [英] How do you post messages in a storage queue from a PowerShell Job

查看:74
本文介绍了如何通过PowerShell作业将消息发布到存储队列中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$queue = Get-AzureStorageQueue -Name 'itemsqueue' -Context $context 1..1 | % {
    $msgContent = "This is message $_"
    $queueMessage = New-Object -TypeName Microsoft.WindowsAzure.Storage.Queue.CloudQueueMessage -ArgumentList $msgContent

    Start-Job {
        $queue.CloudQueue.AddMessage($msgContent)
    }
}

Get-Job | Receive-Job

Id   名称                                        PSJobTypeName 状态       HasMoreData    位置 
-    ----                                       -------------   -----        -----------     --------   
281   Job281        BackgroundJob  正在运行真实                                     本地主机 
您不能在空值表达式上调用方法.
    + CategoryInfo         :InvalidOperation:(:) [],RuntimeException
    + FullyQualifiedErrorId:InvokeMethodOnNull
    + PSComputerName       :本地主机

Id     Name            PSJobTypeName   State         HasMoreData     Location   
--     ----            -------------   -----         -----------     --------   
281    Job281          BackgroundJob   Running       True            localhost  
You cannot call a method on a null-valued expression.
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull
    + PSComputerName        : localhost


在存储队列中并行推送消息的正确方法是什么?

What is the right way of pushing messages in an storage queue in parallel?

我还尝试传递Params() 去工作. $ queue或$ queue.CloudQueue失败

I also tried passing Params()  to the job. $queue or $queue.CloudQueue failed

谢谢!

推荐答案

@Carlos Raul Garcia, 

您可以使用以下语法使用powershell将消息发布到队列:

@Carlos Raul Garcia, 

You can post a message to queues using powershell using the following syntax:

Add-AzureRmStorageQueueMessage -queue


queue -message @ {"type" ="copy";"vhdname" ="newvhd.vhd" ;"sourceStorageAccount" ="pmcstorage05";"subscription" ="mysubscription"}
queue -message @{"type"="copy";"vhdname"="newvhd.vhd";"sourceStorageAccount"="pmcstorage05";"subscription"="mysubscription"}

或以下内容:


message = @ {"type" ="copy"; "vhdname" ="newvhd01.vhd"; ;"sourceStorageAccount" ="pmcstorage05"; "subscription" ="mysubscription"} Add-AzureRmStorageQueueMessage -queue
message = @{"type"="copy"; "vhdname"="newvhd01.vhd"; "sourceStorageAccount"="pmcstorage05"; "subscription"="mysubscription"} Add-AzureRmStorageQueueMessage -queue


这篇关于如何通过PowerShell作业将消息发布到存储队列中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆