unicode - Azure 服务总线消息触发 Azure 函数(unicode 消息)
问题描述
关于使用 Azure Service Bus 发送带有 unicode(中文字符)的消息的问题。使用此代码发送带有 unicode 字符的消息后:
string msgBody = JsonConvert.SerializeObject(msg);
var message = new Message(Encoding.Unicode.GetBytes(msgBody));
await QueueClient.SendAsync(message);
await QueueClient.CloseAsync();
其中 msg 包含中文字符。由消息触发的 Azure 函数因异常而崩溃:
System.Private.CoreLib:执行函数时出现异常:Function1。Microsoft.Azure.WebJobs.Host:异常绑定参数“myQueueItem”。Microsoft.Azure.WebJobs.ServiceBus:ContentType 为“null”的消息无法反序列化为带有以下消息的字符串:“反序列化 System.String 类型的对象时出错。输入源的格式不正确。'。System.Private.DataContractSerialization:反序列化 System.String 类型的对象时出错。输入源的格式不正确。System.Private.DataContractSerialization:输入源的格式不正确。
知道使用 unicode 消息触发 Azure 功能吗?
解决方案
固定的!UTF8 似乎运行良好。
推荐阅读
- asp.net - SignalR WebSockets 在本地工作,但不在服务器上
- python - 删除字符串变量的最后 n 个字符,其中 n 是变量
- integration - 如何将 Gatling 开源与 Dynatrace 集成
- python - Keras 模型中的反向传播不影响所有层?
- archlinux - 将 Neomutt 邮件存储在外部磁盘中
- react-router - Nextjs:在 HOC 组件中重定向时出错
- pyspark - Pyspark 交叉连接
- node.js - 如何将数据发送到 GUI
- python - 如何,我可以将 Combobox.get 与 python 中的 mysal 数据进行比较
- mysql - 最后一个非空值的 WHERE 子句