[英]Can't send test message with Firebase because there of "no test decives configured"
[英]function app can't send message to event grid: The given key '1' was not present in the dictionary
我有一個 function 應用程序,其中一個 function 將消息發送到事件網格,而同一個 function 應用程序中的一個 function 訂閱了這個事件網格主題。 向事件網格發送消息的 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);
}
執行 await client.SendEventAsync(egEvent) 時的代碼給我錯誤:
The given key '1' was not present in the dictionary.
我使用 azure 門戶復制到剪貼板小部件並粘貼代碼來獲取密鑰。 我還嘗試使用確認密鑰的 powershell。
az eventgrid topic key list --name eventgridtopicname --resource-group myresourcegroup --query "key1"
我正在使用Azure.Messaging.EventGrid v4.12.0並且還嘗試了 Microsoft.Azure.Eventgrid v.3.2.0,我在 VS2022 上安裝了最新更新。
這看起來不像是 Acces Key 是否有效的問題,您已經通過 Powershell 中的 CLI 命令驗證排除了它。
錯誤消息中的“鍵”可能是指字典類型中缺少的項目,我懷疑是這樣的: machinePartTransformTelemetry[1]
有關錯誤消息的更多上下文:字典中不存在給定的鍵。 哪把鑰匙?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.