gpt4 book ai didi

Azure 函数输出绑定(bind)事件网格托管标识

转载 作者:行者123 更新时间:2023-12-03 03:34:35 28 4
gpt4 key购买 nike

我正在尝试编写一个具有事件网格输出绑定(bind)的 Azure 函数,如何将其配置为使用管理身份而不是主题 key ?

    [Function("TestEventGrid")]
[EventGridOutput(TopicEndpointUri = "MyEventGridTopicUriSetting", TopicKeySetting = "MyEventGridTopicKeySetting")]
public async Task<MyEvent> Run([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData req)
{
return await Task.FromResult(new MyEvent
{
Id = "123",
Subject = "sub",
EventType = "myevent",
EventTime = DateTime.Now,
Data = new TestData(),
DataVersion = "1.0"
});
}

最佳答案

使用 EventGridAsyncCollector 代替 EventGridAttribute,它位于 nextdoor :

enter image description here

EventGridAsyncCollectorthe scenes 后面使用 EventGridPublisherClient :

public EventGridPublisherClient(System.Uri endpoint, Azure.AzureKeyCredential credential) { }

Azure.AzureKeyCredential 凭据 就是您正在寻找的内容。

更新:您应该完全放弃 EventGridAttribute 并转而使用较低级别的 EventGridPublisherClient。以下是如何使用它的链接:https://github.com/Azure/azure-sdk-for-net/tree/main/sdk/eventgrid/Azure.Messaging.EventGrid#authenticate-using-azure-active-directory

关于Azure 函数输出绑定(bind)事件网格托管标识,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73815662/

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