gpt4 book ai didi

c# - Azure队列存储 Visual Studio 本地主机从QueueClient发送到毒队列的所有队列消息

转载 作者:行者123 更新时间:2023-12-03 04:00:56 24 4
gpt4 key购买 nike

我在 Visual Studio 中有 2 个项目,一个 Web API 和一个具有 Azure 队列存储触发器函数的 Azure 函数项目。我正在使用 Azure 存储模拟器。两者都使用 UseUseDevelopmentStorage=true 作为连接字符串。队列客户端正在接收 201,我在存储模拟器中看到该消息。但触发函数永远不会被触发。我没有看到任何控制台错误。但是,如果我使用存储模拟器添加消息,则会触发触发器。所以触发功能确实可以工作,但只能通过模拟器。 QueueClient 代码正在运行,我收到 201 并在模拟器中看到该消息。我在本地完成这一切,我还没有在 Azure 中创建队列。我不明白这怎么会成为一个问题,但我想我应该补充一点。

我的队列客户端代码是

    public async Task InsertCustomer()
{
var queueClient = new QueueClient(_configuration["StorageConnectionString"], "customer-items");
var myString = "Testing";
byte[] bytes = Encoding.Default.GetBytes(myString);
myString = Encoding.UTF8.GetString(bytes);
await queueClient.CreateIfNotExistsAsync();
//just here for debugging
var result = await queueClient.SendMessageAsync(myString);
}

URI 正在将其发送到 http://127.0.0.1:10001/devstoreaccount1/customer-items

队列触发器是

public static class InsertCustomerQueue
{
[FunctionName("InsertCustomer")]
public static void Run([QueueTrigger("customer-items", Connection = "AzureWebJobsStorage")] string myQueueItem, ILogger log)
{
try
{
log.LogInformation($"C# Queue trigger function processed: {myQueueItem}");
}
catch (Exception ex)
{
log.LogInformation(ex.ToString());
}
}
}

}

我正在以管理员身份运行 Visual Studio(2019 社区)和模拟器。这似乎是理所当然的事,但我无法弄清楚。

最佳答案

谢谢大家,现在明白了。我以为字符串需要是UTF-8,但事实证明它需要是base64编码的。

关于c# - Azure队列存储 Visual Studio 本地主机从QueueClient发送到毒队列的所有队列消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62400706/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com