简体   繁体   English

如何将消息推送到 azure 服务总线并触发 azure 函数以记录它看到的消息

[英]how to push a message onto azure service bus and trigger an azure function to log it sees the message

I'm experimenting with Azure and Azure Service Bus.我正在试验 Azure 和 Azure 服务总线。 I just want to push messages onto a queue and then have my C# azure function log that is sees the message.我只想将消息推送到队列中,然后让我的 C# azure 函数日志看到消息。 I'm struggling to get it working.我正在努力让它工作。 I've created an azure account, created a resource group, created a service bus, downloaded storage explorer.我创建了一个 azure 帐户,创建了一个资源组,创建了一个服务总线,下载了存储资源管理器。 I have the shared access policy 'RootManageSharedAccessKey' which has the 'managed' option checked in the portal.我有共享访问策略“RootManageSharedAccessKey”,它在门户中选中了“托管”选项。

So guessing what I do next?那么猜猜我接下来要做什么? I've gone to azure functions and created a function, shown below, in the azure portal.我已经转到 azure 函数并在 azure 门户中创建了一个函数,如下所示。 When I open up storage explorer I'm not sure what option to use to connect to my azure instance with?当我打开存储资源管理器时,我不确定使用什么选项连接到我的 azure 实例?

Any help?有什么帮助吗? Thank you!谢谢!

azure function天蓝色的功能

using System;
using System.Threading.Tasks;

public static void Run(string myQueueItem, ILogger log)
{
    log.LogInformation($"C# ServiceBus queue trigger function processed message: {myQueueItem}");
}

Using Service Bus Explorer you can connect to Azure Service Bus and administer messaging entities.使用服务总线资源管理器可以连接到 Azure 服务总线并管理消息传递实体。 You can download the tool here .您可以在此处下载该工具。 在此处输入图片说明

Once you download the tool you run “ServiceBusExplorer.exe” In the Service Bus Explorer go to File Connect下载工具后,运行“ServiceBusExplorer.exe” 在服务总线资源管理器中转到文件连接

Enter Connection string which you can find on in输入您可以在其中找到的连接字符串

Azure portal Dashboard --> Service Bus --> Shared access policies Azure 门户仪表板 --> 服务总线 --> 共享访问策略

在此处输入图片说明

After connected Successfully you will be able to see all the topics/queues in the connected servicebus select the Queue that you wanted Access连接成功后,您将能够看到连接的服务总线中的所有主题/队列 选择您想要访问的队列

and then click on Send Messages as follows it will populate message box then you have to write the content of your message in required format(json, xml etc) and send it.然后单击发送消息,如下所示,它将填充消息框,然后您必须以所需格式(json、xml 等)编写消息内容并发送。 在此处输入图片说明

Don't confuse Azure Service Bus Queues with Azure Storage Queues.不要将 Azure 服务总线队列与 Azure 存储队列混淆。 You can use Azure Storage Explorer to see Azure Storage Queues, but not Azure Service Bus Queues.可以使用 Azure 存储资源管理器查看 Azure 存储队列,但不能查看 Azure 服务总线队列。 To access Azure Service Bus Queues, download Azure Service Bus Explorer here To my knowledge, there is no binary distribution and you're going to need to build it yourself after cloning the repo.要访问 Azure 服务总线队列,请在此处下载 Azure 服务总线资源管理器据我所知,没有二进制分发版,您需要在克隆存储库后自行构建它。 Once you run it and connect to your Service Bus Namespace, you can create a queue and insert messages into it.运行它并连接到服务总线命名空间后,您可以创建一个队列并将消息插入其中。

Next, you'll need to define a ServiceBusTrigger on your Azure Function.接下来,需要在 Azure 函数上定义 ServiceBusTrigger。 This is an attribute that will monitor the specified Service Bus Queue and poll for new messages.这是一个属性,它将监视指定的服务总线队列并轮询新消息。 When it finds one, it'll call your function.当它找到一个时,它会调用你的函数。 Assuming you're using Azure Functions v2, here's a Microsoft tutorial to do this .假设您使用的是 Azure Functions v2, 这里有一个 Microsoft 教程来执行此操作

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 How to trigger both Azure Function by Service Bus message and output message to Service Bus within single Azure Function - How to trigger both Azure Function by Service Bus message and output message to Service Bus within single Azure Function 具有服务总线触发器的Azure Function中的自动转发消息 - Auto forward message in Azure Function with Service Bus trigger 使用代理消息在门户中测试Azure功能服务总线触发器 - Testing an Azure Function Service Bus Trigger in the Portal with a Brokered Message 如何从azure功能向azure服务总线添加消息? - How to add message to azure service bus from azure function? 如何将二进制消息从 Azure 函数发送到 Azure 服务总线 - How to send a binary message from Azure Function to Azure Service Bus 如果 Azure 服务总线队列触发器功能失败,如何将队列消息返回到 Azure 服务总线队列 - How to return queue message to Azure Service Bus Queue if Azure Service Bus Queue Trigger Func Fails 如何在Azure Service总线中推送最大长度消息 - How to push the Maximum length message in azure service bus 当新消息进入服务总线队列时,Azure 函数(服务总线触发器)不启动 - Azure Function (Service Bus Trigger) Not Getting started when a new message comes into the service bus queue azure功能服务总线输出消息属性 - azure function service bus output message properties Azure功能未将消息发布到服务总线 - Azure Function Not Publishing Message to Service Bus
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM