You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure Blob Trigger动态路径配置失败及解决方案咨询

Fixing Azure Blob Trigger Path Binding Conflict for Event Hub Capture

Hey there, let's break down why you're hitting that An item with the same key has already been added. Key: mm error and how to fix it properly.

What's Causing the Error?

The issue comes down to duplicate placeholder keys in your Blob Trigger path. When you use {mm} (for minutes) and {ss} (for seconds), these clash with Azure Functions' internal binding logic—some of these shorthand format identifiers are either reserved or get misinterpreted as duplicate keys during the trigger's indexing phase.

The Correct Path Configuration

Azure Functions Blob Trigger supports custom-named placeholders for dynamic path segments, so we just need to use clear, non-conflicting names that map directly to the structure of your Event Hub Capture output. Your Capture path is {Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}, so we'll adjust the trigger's path to match with explicit placeholder names.

Updated Code Example

@FunctionName("AzureBlogTriggerFn5")
public void blobHandler(
    @BlobTrigger(
        name = "content", 
        path = "uts-blobcontainer-nb-dev/uts-eventhubns/uts-nb-eventhub/{partitionId}/{year}/{month}/{day}/{hour}/{minute}/{second}/{fileName}", 
        dataType = "binary", 
        connection = "AzureWebJobsStorage"
    ) byte[] content,
    @BindingName("partitionId") String partitionId,
    @BindingName("year") String year,
    @BindingName("month") String month,
    @BindingName("day") String day,
    @BindingName("hour") String hour,
    @BindingName("minute") String minute,
    @BindingName("second") String second,
    @BindingName("fileName") String fileName,
    final ExecutionContext context
) throws StorageException, IOException, URISyntaxException, InvalidKeyException, InterruptedException {
    context.getLogger().info("Java Blob trigger function processed a blob. " +
        "\n File Name: " + fileName +
        "\n Partition ID: " + partitionId +
        "\n Capture Time: " + year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second +
        "\n Size: " + content.length + " Bytes");
}

Key Changes Explained

  • Replace conflicting placeholders: Swap out {partition} → {partitionId}, {yyyy} → {year}, {MM} → {month}, {dd} → {day}, {HH} → {hour}, {mm} → {minute}, {ss} → {second}. These explicit names avoid clashes with any reserved or internal keys.
  • Inject dynamic values (optional): If you need to use the partition ID or timestamp values in your code, add @BindingName annotations for each placeholder—this lets you access those values directly as method parameters.
  • Match Capture path structure: Ensure each placeholder lines up exactly with the segments in your Event Hub Capture path (e.g., PartitionId in Capture maps to {partitionId} in the trigger path) so the trigger correctly detects new blobs.

Quick Checks to Verify

  • Double-check that your container name (uts-blobcontainer-nb-dev), Event Hub namespace (uts-eventhubns), and Event Hub name (uts-nb-eventhub) match exactly what's configured in your Event Hub Capture settings.
  • The trigger will automatically handle two-digit time/date segments (like 05 for May or 09 for 9 AM) as string values, no extra formatting needed.

内容的提问来源于stack exchange,提问作者Niranjan Reddy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:10:01