diff --git a/README.md b/README.md index 4037c6c..a64a68f 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,33 @@ Binary data is represented as `byte[]` or `Byte[]` in your Azure functions code. Empty input values could be `null` as your functions argument, but a recommended way to deal with potential empty values is to use `Optional` type. +### Blob Storage SDK types + +Support for binding directly to Azure Blob Storage SDK types is currently in preview. `BlobClient` and `BlobContainerClient` parameters require: + +* The `JAVA_ENABLE_SDK_TYPES` application setting set to `true`. +* Azure Functions Maven Plugin version 1.38.0 or later, or the corresponding Gradle plugin support. + +Without these settings, the Java worker treats the parameter as a regular POJO and attempts to deserialize the blob content into it. + +For example, a blob trigger can access blob properties through `BlobClient`: + +```java +@FunctionName("processBlob") +public void run( + @BlobTrigger( + name = "content", + path = "images/{name}", + connection = "AzureWebJobsStorage") BlobClient blob, + @BindingName("name") String filename, + ExecutionContext context +) { + context.getLogger().info("Name: " + filename + ", Size: " + blob.getProperties().getBlobSize() + " bytes"); +} +``` + +Only one SDK type can be used in a function definition. See the [Java developer guide](https://learn.microsoft.com/azure/azure-functions/functions-reference-java#sdk-types) for configuration, supported types, and troubleshooting information. + ## Inputs diff --git a/src/main/java/com/microsoft/azure/functions/annotation/BlobTrigger.java b/src/main/java/com/microsoft/azure/functions/annotation/BlobTrigger.java index 932e409..b46499c 100644 --- a/src/main/java/com/microsoft/azure/functions/annotation/BlobTrigger.java +++ b/src/main/java/com/microsoft/azure/functions/annotation/BlobTrigger.java @@ -19,8 +19,12 @@ *
  • Any native Java types such as int, String, byte[]
  • *
  • Nullable values using Optional<T>
  • *
  • Any POJO type
  • + *
  • Azure Blob Storage SDK types {@code BlobClient} and {@code BlobContainerClient} (preview)
  • * * + *

    SDK type parameters require the {@code JAVA_ENABLE_SDK_TYPES} application setting to be {@code true} and + * Azure Functions Maven Plugin version 1.38.0 or later (or corresponding Gradle plugin support). Without SDK type + * support enabled, the Java worker treats the parameter as a POJO.

    * *

    The following example shows a Java function that logs the filename and size when a blob is added or updated * in the "samples-workitems" container: