首页 > 解决方案 > How can we pass topic and subscription name from yaml in azure function - java

问题描述

@FunctionName("TestHandler")
public void Handler(
   @ServiceBusTopicTrigger(
           name = "ServiceBus",
           topicName = "topicname",
           connection = "ServiceBusConnectionString",
           subscriptionName = "subscriptionName")
       String message,
   final ExecutionContext context) {}

I want to fetch subscriptionName value from deployment.yaml , config map settings. How can I get the value from there.

标签: javaazureazure-functionskubernetes-helm

解决方案


不可能。


这是一个函数设置,只能在 中指定function.json,如果 Java 是生成的,而不是由您编写的。所以它必须在代码中。

在某些例外情况下,您可以在代码中指定一个特殊值,它指的是应用程序设置(例如,请参阅 SheduleExpression以了解计时器触发器)。但我在服务总线绑定中看不到任何类似的东西。

您可以通过subscriptionName = "%MY_SUBSCRIPTION_CONFIG%"在注释/代码中指定并添加MY_SUBSCRIPTION_CONFIG到应用程序设置(通过local.settings.json或其他方式)来尝试一下,看看它是否有效。

否则,请联系 Azure 支持以确认一种或另一种方式。


推荐阅读