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

如何配置Blob Trigger绑定以排除含Thumbnails的URL路径?

How to Exclude Blob Trigger for Paths Containing "thumbnails"

The pattern you tried (BlobTrigger("ProfilePhoto/*~thumbnails*/{name}")) doesn't work because Azure Functions Blob Triggers use glob matching (not regular expressions), and the ~ character is treated as a literal here. This means your pattern is actually looking for blobs with ~thumbnails~ in their path, not excluding those with thumbnails. Let's fix this with two practical solutions:


Solution 1: Filter Inside the Function (Quickest Fix)

The simplest approach is to check the blob's full path directly in your function code and exit early if it contains "thumbnails". This avoids any trigger configuration headaches.

Example in C#:

[FunctionName("ProcessProfilePhoto")]
public static void Run(
    [BlobTrigger("ProfilePhoto/{name}", Connection = "AzureWebJobsStorage")] Stream myBlob,
    string name,
    string blobTrigger, // Gets the full blob path
    ILogger log)
{
    // Skip blobs with "thumbnails" in their path
    if (blobTrigger.Contains("thumbnails", StringComparison.OrdinalIgnoreCase))
    {
        log.LogInformation($"Skipping thumbnail blob: {blobTrigger}");
        return;
    }

    // Your normal processing logic here
    log.LogInformation($"Processing blob: {name}");
}

Example in Python:

import logging
import azure.functions as func

def main(myblob: func.InputStream):
    # Skip blobs with "thumbnails" in their path
    if "thumbnails" in myblob.name.lower():
        logging.info(f"Skipping thumbnail blob: {myblob.name}")
        return

    # Your normal processing logic here
    logging.info(f"Processing blob: {myblob.name}")

Solution 2: Use Azure Event Grid (Cleaner Long-Term Fix)

If you want to avoid triggering the function entirely for thumbnail blobs, switch to using Azure Event Grid instead of the native Blob Trigger. Event Grid supports filtering rules to exclude specific paths at the source.

Here's how to set it up:

  1. Create an Event Grid subscription for your storage account, targeting your Azure Function as the endpoint.
  2. In the subscription's filtering settings, add an exclude filter for the subject field, matching paths that contain /thumbnails/ (adjust the pattern to match your exact folder structure).
  3. Only blob creation events that don't include "thumbnails" in their path will now trigger your function.

Why Your Original Configuration Failed

To clarify: Blob Trigger glob patterns have strict rules:

  • * matches any characters within a single folder (doesn't cross / separators)
  • ** matches any characters across multiple folders
  • There is no built-in syntax for negative matching (excluding paths) directly in the trigger path.

Your original pattern was looking for blobs with the literal string ~thumbnails~ in their path, which isn't what you intended.

内容的提问来源于stack exchange,提问作者Tirupathi Temburu

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 09:25:35