简体   繁体   English

为什么在创建 QueueTrigger WebJob 函数时会看到 FunctionIndexingException?

[英]Why do I see a FunctionIndexingException when creating a QueueTrigger WebJob Function?

I created a function like this我创建了一个这样的函数

public static Task HandleStorageQueueMessageAsync(
    [QueueTrigger("%QueueName%", Connection = "%ConnectionStringName%")] string body,
    TextWriter logger)
    {
        if (logger == null)
        {
            throw new ArgumentNullException(nameof(logger));
        }

        logger.WriteLine(body);
        return Task.CompletedTask;
    }

The queue name and the connection string name come from my configuration that has an INameResolver to get the values.队列名称和连接字符串名称来自我的配置,它有一个INameResolver来获取值。 The connection string itself I put from my secret store into the app config at app start.我在应用程序启动时从我的秘密商店放入应用程序配置的连接字符串本身。 If the connection string is a normal storage connection string granting all permissions for the whole account, the method works like expected.如果连接字符串是为整个帐户授予所有权限的普通存储连接字符串,则该方法按预期工作。

However, in my scenario I am getting an SAS from a partner team that only offers read access to a single queue.但是,在我的场景中,我从合作伙伴团队获得了一个 SAS,该团队仅提供对单个队列的读取访问权限。 I created a storage connection string from that which looks similar like我从中创建了一个存储连接字符串,它看起来像

QueueEndpoint=https://accountname.queue.core.windows.net;SharedAccessSignature=st=2017-09-24T07%3A29%3A00Z&se=2019-09-25T07%3A29%3A00Z&sp=r&sv=2018-03-28&sig=token

(I tried successfully to connect using this connection string in Microsoft Azure Storage Explorer) (我尝试在 Microsoft Azure 存储资源管理器中使用此连接字符串成功连接)

The queue name used in the QueueTrigger attribute is also gathered from the SAS QueueTrigger属性中使用的队列名称也是从 SAS 中收集的

However, now I am getting the following exceptions但是,现在我收到以下异常

$exception  {"Error indexing method 'Functions.HandleStorageQueueMessageAsync'"}    Microsoft.Azure.WebJobs.Host.Indexers.FunctionIndexingException
InnerException  {"No blob endpoint configured."}    System.Exception {System.InvalidOperationException}

If you look at the connection string, you can see the exception is right.如果查看连接字符串,您可以看到异常是正确的。 I did not configure the blob endpoint.我没有配置 blob 端点。 However I also don't have access to it and neither do I want to use it.但是,我也无权访问它,也不想使用它。 I'm using the storage account only for this QueueTrigger .我仅将此存储帐户用于此QueueTrigger

I am using Microsoft.Azure.WebJobs v2.2.0.我正在使用 Microsoft.Azure.WebJobs v2.2.0。 Other dependencies prevent me from upgrading to a v3.x其他依赖项阻止我升级到 v3.x

What is the recommended way for consuming messages from a storage queue when only a SAS URI with read access to a single queue is available?当只有具有对单个队列的读取访问权限的 SAS URI 可用时,从存储队列使用消息的推荐方法是什么? If I am already on the right path, what do I need to do in order to get rid of the exception?如果我已经在正确的道路上,我需要做什么才能摆脱异常?

As you have seen, v2 WebJobs SDK requires access to blob endpoint as well.如您所见,v2 WebJobs SDK 也需要访问 blob 端点。 I am afraid it's by design, using connection string without full access like SAS is an improvement tracked but not realized yet.恐怕这是设计使然,使用没有完全访问权限的连接字符串(如 SAS)是一种已跟踪但尚未实现的改进

Here are the permissions required by v2 SDK.以下是 v2 SDK 所需的权限。 It needs to get Blob Service properties(Blob,Service,Read) and Queue Metadata and process messages(Queue,Container&Object,Read&Process).它需要获取 Blob 服务属性(Blob、Service、Read)和队列元数据并处理消息(Queue、Container&Object、Read&Process)。 在此处输入图片说明

Queue Trigger is to get messages and delete them after processing, so SAS requires Process permission. Queue Trigger是获取消息,处理后删除,所以SAS需要Process权限。 It means the SAS string you got is not authorized correctly even if SDK doesn't require blob access.这意味着即使 SDK 不需要 blob 访问,您获得的 SAS 字符串也未正确授权。

You could ask partner team to generate SAS Connection String on Azure portal with minimum permissions above.您可以要求合作伙伴团队以上述最低权限在 Azure 门户上生成 SAS 连接字符串。 If they can't provide blob access, v3 SDK seems an option to try.如果他们不能提供 blob 访问,v3 SDK 似乎是一个可以尝试的选项。

But there are some problems 1. Other dependencies prevent updating as you mentioned 2. v3 SDK is based on .NET Core which means code changes can't be avoided.但是有一些问题 1.其他依赖项阻止更新,正如您提到的 2.v3 SDK基于.NET Core,这意味着无法避免代码更改。 3. v3 SDK document and samples are still under construction right now. 3. v3 SDK 文档和示例目前仍在构建中

I was having a load of issues getting a SAS token to work for a QueueTrigger.我在让 SAS 令牌为 QueueTrigger 工作时遇到了很多问题。

Not having blob included was my problem.没有包含 blob 是我的问题。 Thanks Jerry!谢谢杰瑞!

Slightly newer screenshot (I need add also):稍微更新的屏幕截图(我还需要添加): 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM