放置令牌失败。状态码:404 – Azure Function(Java)未能由服务总线触发。

huangapple go评论85阅读模式
英文:

Put token failed. status-code: 404 - Azure Function (Java) fails get triggered by Service Bus

问题

我尝试使用VS Code创建基于Java的简单Azure Functions。
我尝试从Service Bus获取主题消息。

//local.settings.json (SAS Policy: RadioTopicPolicy = Manage/Read/Listen)

"topicconnstring":"Endpoint=sb://111standardsb.servicebus.windows.net/;SharedAccessKeyName=RadioTopicPolicy;SharedAccessKey 
       =11111nuAmrb16c3/cGaxe0dYGTz/tiBebTI+peG4zE=;"

此函数由Service Bus主题触发,并将数据存储到Data Lake
绑定示例

package com.function;

import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;

/**
 * 使用Azure Storage Queue触发的Azure函数。
 */ 
public class TopicTriggerCosmosOutput {
    /**
     * 当在指定路径接收新消息时,将调用此函数。消息内容将作为此函数的输入提供。
     */ 

    @FunctionName("TopicTriggerDataLakeOutput")
    public void run(
        @ServiceBusTopicTrigger(
            name = "message",
            topicName = "radioTopic",
            subscriptionName = "RadioSubscription",
            connection = "topicconnstring"
        ) String message,
        final ExecutionContext context
    ) {
        context.getLogger().info(message);
    }
}

在VS Code中调试时出现的错误:

[3.4.2020 12.29.30] 消息处理错误
(Action=Receive,
ClientID=MessageReceiver1radioTopic/Subscriptions/RadioSubscription,
EntityPath=radioTopic/Subscriptions/RadioSubscription, Endpoint=mystandardsb.servicebus.windows.net)
[3.4.2020 12.29.30] Microsoft.Azure.ServiceBus: 放置令牌失败。 状态码:404,状态-
说明:消息实体
'sb://mystandardsb.servicebus.windows.net/radioTopic/Subscriptions/RadioSubscription' 无法找到。 要了解更多信息,请访问
https://aka.ms/sbResourceMgrExceptions。 跟踪ID:67df5bb7-87fb-48ca-
9e8e-6829c4e3a4a1_G25,
SystemTracker:mystandardsb.servicebus.windows.net:radioTopic/Subscriptions/RadioSubscription,
时间戳:2020-04-03T12:29:30。

英文:

I try to create simple Java based Azure Functions with VS Code.
I try to get Topic message from Service Bus.

//local.settings.json (SAS Policy: RadioTopicPolicy = Manage/Read/Listen)

"topicconnstring":"Endpoint=sb://111standardsb.servicebus.windows.net/;SharedAccessKeyName=RadioTopicPolicy;SharedAccessKey 
       =11111nuAmrb16c3/cGaxe0dYGTz/tiBebTI+peG4zE=;"

This Function get triggered by Service Bus Topic and store data to Data Lake
binding example

package com.function;

import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;

/**
 * Azure Functions with Azure Storage Queue trigger.
*/ 
public class TopicTriggerCosmosOutput {
     /**
     * This function will be invoked when a new message is received at the specified path. The 
message contents are provided as input to this function.
    */ 

    @FunctionName("TopicTriggerDataLakeOutput")
    public void run(
        @ServiceBusTopicTrigger(
            name = "message",
            topicName = "radioTopic",
            subscriptionName = "RadioSubscription",
            connection = "topicconnstring"
        ) String message,
        final ExecutionContext context
    ) {
        context.getLogger().info(message);
    }

}

Errors when debugging in VS Code:

[3.4.2020 12.29.30] Message processing error 
    (Action=Receive, 
 
 ClientId=MessageReceiver1radioTopic/Subscriptions/RadioSubscription, 
    EntityPath=radioTopic/Subscriptions/RadioSubscription, Endpoint=mystandardsb.servicebus.windows.net)
    [3.4.2020 12.29.30] Microsoft.Azure.ServiceBus: Put token failed. status-code: 404, status- 
   description: The messaging entity 
    
 'sb://mystandardsb.servicebus.windows.net/radioTopic/Subscriptions/RadioSubscription' could not be 
    found. To know more visit 
    https://aka.ms/sbResourceMgrExceptions.  TrackingId:67df5bb7-87fb-48ca- 
    9e8e-6829c4e3a4a1_G25, 
    SystemTracker:mystandardsb.servicebus.windows.net:radioTopic/Subscriptions/RadioSubscription, 
    Timestamp:2020-04-03T12:29:30.

答案1

得分: 1

这个错误意味着自动转发目标实体的目标不存在。在创建源之前,目标实体(队列或主题)必须存在。在创建目标实体后重试。

查看一下这个文档:

https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-resource-manager-exceptions#error-bad-request

我注意到你说

> 在 Azure 服务总线中有一个名为“Radio”的服务总线主题和一个名为“RadioSubscription”的订阅。还有一个名为“RadioTopicPolicy”的策略。

所以你的函数应该像这样:

@FunctionName("TopicTriggerDataLakeOutput")
public void run(
    @ServiceBusTopicTrigger(
        name = "message",
        topicName = "Radio",
        subscriptionName = "RadioSubscription",
        connection = "topicconnstring"
    ) String message,
    final ExecutionContext context
) {
    context.getLogger().info(message);
}

并确保你的 SAS 令牌的主键是正确的。希望能有所帮助。:)

英文:

This error means the destination for the autoforwarding destination entity doesn't exist. The destination entity (queue or topic), must exist before the source is created. Retry after creating the destination entity.

Have a look of this doc:

https://learn.microsoft.com/en-us/azure/service-bus-messaging/service-bus-resource-manager-exceptions#error-bad-request

I notice that you say

> There is "Radio" Service Bus Topic and "RadioSubscription"
> Subscription in Azure Service Bus. There is "RadioTopicPolicy"

So your function should be like this:

@FunctionName("TopicTriggerDataLakeOutput")
    public void run(
        @ServiceBusTopicTrigger(
            name = "message",
            topicName = "Radio",
            subscriptionName = "RadioSubscription",
            connection = "topicconnstring"
        ) String message,
        final ExecutionContext context
    ) {
        context.getLogger().info(message);
    }

And make sure the primary key of your SAS token is correct. Hope it helps.:)

huangapple
  • 本文由 发表于 2020年4月3日 20:41:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/61012147.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定