是否有任何 C# 示例代码用于读取 Azure 事件中心存档文件(Avro 格式)?
我正在尝试使用 Microsoft.Hadoop.Avro 库。我使用 java avro 工具转储模式,该工具生成以下内容:
{
""type"":""record"",
""name"":""EventData"",
""namespace"":""Microsoft.ServiceBus.Messaging"",
""fields"":[
{""name"":""SequenceNumber"",""type"":""long""},
{""name"":""Offset"",""type"":""string""},
{""name"":""EnqueuedTimeUtc"",""type"":""string""},
{""name"":""SystemProperties"",""type"":{ ""type"":""map"",""values"":[""long"",""double"",""string"",""bytes""]}},
{""name"":""Properties"",""type"":{ ""type"":""map"",""values"":[""long"",""double"",""string"",""bytes"", ""null""]}},
{""name"":""Body"",""type"":[""null"",""bytes""]}
]
}
Run Code Online (Sandbox Code Playgroud)
但是,当尝试反序列化文件以读回数据时,如下所示:
using (var reader = AvroContainer.CreateReader<EventData>(stream))
{
using (var streamReader = new SequentialReader<EventData>(reader))
{
foreach (EventData dta in streamReader.Objects)
{
//stuff here
}
}
}
Run Code Online (Sandbox Code Playgroud)
当传递生产者端使用的实际 EventData 类型时它不起作用,因此我尝试创建一个用 DataContract 属性标记的特殊类,如下所示:
[DataContract(Namespace = "Microsoft.ServiceBus.Messaging")]
public class EventData
{
[DataMember(Name = "SequenceNumber")]
public long SequenceNumber { get; set; }
[DataMember(Name = "Offset")]
public string …Run Code Online (Sandbox Code Playgroud) 我将 IdentityServer4 作为身份验证系统运行,以使用 Google 和 Amazon 以及本地帐户。我有一个单独的网络应用程序,使用 IdentityServer4 系统作为 oidc 身份验证提供程序,并且似乎可以进行身份验证和颁发令牌。问题是它在身份验证后不维护 returnUrl。我正在使用通过 Redis 分布式缓存内置到 Id4 的 OIDC StateDataFormatterCache,并在 Redis 中验证它正在写入重定向,甚至是我在挑战时添加的测试参数。
身份验证后,它不会将我重定向回原始网址,并且当我尝试访问质询中设置的参数和 AuthenticationProperties 时,它们在身份验证后似乎不存在。
我已经单步执行了 IdentityServer4 端的代码,其中本地和外部回调的登录信息以及 returnUrl 从未显示在那里。我假设 OIDC StateDataFormatterCache 拦截此行为是为了防止潜在的长 url 问题,并且应该拦截响应并注入返回 url。这部分似乎不起作用,所以我试图看看是否可以将自己的自定义参数粘贴到 auth props 中,并在 auth 发生后将其取出,但结果是空的。AuthenticationProperties 似乎只有 access_token、refresh_token、id_token 等,但缺少重定向 url 和我的自定义参数。
services.AddOidcStateDataFormatterCache("oidc");
...
var authProps = new AuthenticationProperties { RedirectUri = originalPath + context.Request.QueryString };
Microsoft.Extensions.Primitives.StringValues stateValue;
if (context.Request.Query.TryGetValue("state", out stateValue))
{
authProps.SetParameter("itk", stateValue);
}
await Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.ChallengeAsync(context,"oidc", authProps); //authProps has custom parameter 'itk' and a redirect
... …Run Code Online (Sandbox Code Playgroud)