简体   繁体   English

function 应用程序无法向事件网格发送消息:字典中不存在给定键“1”

[英]function app can't send message to event grid: The given key '1' was not present in the dictionary

I have a function app with a function that sends message to event grid and a function in this same function app subscribed to this event grid topic.我有一个 function 应用程序,其中一个 function 将消息发送到事件网格,而同一个 function 应用程序中的一个 function 订阅了这个事件网格主题。 The function app that sends message to event grid uses key 1 to auth .向事件网格发送消息的 function 应用程序使用密钥 1 进行身份验证

       //Name of the endpoint of Event grid topic
        string topicEndpoint = transformAlgoSendRMessage_TopicEP;
        //Creating client to publish events to eventgrid topic
        AzureKeyCredential credential = new AzureKeyCredential(eventGridTopic_Key);
        EventGridPublisherClient client = new EventGridPublisherClient(new Uri(topicEndpoint), credential);
        //Creating a sample event with Subject, Eventtype, dataVersion and data
        EventGridEvent egEvent = new EventGridEvent("TransformTelemetry", "TransformAlgorithm.broadcastTransform", "1.0", machinePartTransformTelemetry);
        // Send the event
        
        try
        {
            await client.SendEventAsync(egEvent);
            log.LogInformation("SendRTransformMessage sent transformdata - PosX:" + machinePartTransformTelemetry[1]);
        }
        catch (Exception e)
        {
            log.LogError("Failed to send SendRTransformMessage. " + e.Message);
        }

Code at execution of await client.SendEventAsync(egEvent) gives me error:执行 await client.SendEventAsync(egEvent) 时的代码给我错误:

The given key '1' was not present in the dictionary.

I get the key using the azure portal copy to clipboard widget and paste in code.我使用 azure 门户复制到剪贴板小部件并粘贴代码来获取密钥。 I also tried using powershell which confirmed the key.我还尝试使用确认密钥的 powershell。

az eventgrid topic key list --name eventgridtopicname --resource-group myresourcegroup --query "key1"

在此处输入图像描述

I'm using Azure.Messaging.EventGrid v4.12.0 and also tried Microsoft.Azure.Eventgrid v.3.2.0, I'm on VS2022 with latest update.我正在使用Azure.Messaging.EventGrid v4.12.0并且还尝试了 Microsoft.Azure.Eventgrid v.3.2.0,我在 VS2022 上安装了最新更新。

This doesn't look like an issue of whether the Acces Key was valid or not, and you've ruled it out by verifying via CLI command in Powershell.这看起来不像是 Acces Key 是否有效的问题,您已经通过 Powershell 中的 CLI 命令验证排除了它。

The "key" in the error message is likely in reference to the missing item in the dictionary type, which I suspect is this: machinePartTransformTelemetry[1]错误消息中的“键”可能是指字典类型中缺少的项目,我怀疑是这样的: machinePartTransformTelemetry[1]

More context on the error message: The given key was not present in the dictionary.有关错误消息的更多上下文:字典中不存在给定的键。 Which key? 哪把钥匙?

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

相关问题 无法使用 Firebase 发送测试消息,因为“未配置测试设备” - Can't send test message with Firebase because there of "no test decives configured" Lambda 功能(Go)无法发送 email 与 SES SMTP - Lambda Function(Go) can't send email with SES SMTP 我可以使用 Twilio WhatsApp api 直接向收件人发送消息而不使用加入 [关键字]。 是因为Twilio沙盒吗? - Can i directly send message to recipient using Twilio WhatsApp api without using join [key-word]. Is it because of Twilio Sandbox? BigQuery 可以发送发布/订阅消息吗? - Can BigQuery send a pub/sub message? 我可以向 AWS SNS 发送批量消息吗 - Can I send batch message to AWS SNS 短信服务和Function都可以收到消息吗? 我没有收到消息 Twilio function - Can I receive message in both Messaging service and Function? I don't receive the message in Twilio function 在 AWS 的 Lambda Function 中调用时无法访问“事件”属性 - Can't access 'event' properties when calling it in Lambda Function in AWS 我无法在我的模态 React 中从 map function 发送数据 - I can't send data from map function inside my modal React 如何在不通知的情况下向 ios 应用程序发送数据消息? - How to send a Data Message without notification to ios app? Azure Function 事件中心不触发应用程序 - Azure Function App does not trigger by Event Hub
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM