Skip to content

Commit f1464b6

Browse files
authored
update blob trigger docs with java blob sdk preview details
1 parent ea87e20 commit f1464b6

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

articles/azure-functions/functions-bindings-storage-blob-trigger.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,111 @@ Because the blob trigger uses a queue internally, the maximum number of concurre
577577

578578
Limits apply separately to each function that uses a blob trigger.
579579

580+
::: zone pivot="programming-language-java"
581+
## Preview SDK-types for Blob Storage
582+
583+
### What this preview delivers
584+
585+
Until now a Blob-triggered Java function could receive only raw bytes or strings.
586+
The new **SDK-type binding** lets your function accept a *real* Azure Storage SDK client – either `BlobClient` or `BlobContainerClient`.
587+
588+
* Use every Storage API (leases, tiers, snapshots, …) directly.
589+
* Stream data straight from Storage – no 100 MB blob-size ceiling, no extra memory copies.
590+
* One client instance is cached and reused across invocations for maximum throughput.
591+
592+
### Why you might switch
593+
594+
| Classic binding (`byte[]` / `String`) | SDK-type binding (`BlobClient`, `BlobContainerClient`) |
595+
| -------------------------------------------- | ------------------------------------------------------------ |
596+
| Host downloads blob, sends it to the worker. | Worker streams from Storage itself – lower latency & memory. |
597+
| 100 MB size limit. | No hard limit; streams as big as Storage allows. |
598+
| Only read/write bytes. | Full SDK surface: metadata, ACLs, legal hold, etc. |
599+
600+
### What you need
601+
602+
* Turn the feature on by setting `JAVA_ENABLE_SDK_TYPES` to `"true"` in your
603+
app's settings.
604+
* **azure-functions-maven-plugin** (or Gradle plug-in) ≥ **1.38.0** – detects SDK-type parameters during build and adds the flag that activates the middleware.
605+
* Your function app must reference:
606+
607+
* `azure-storage-blob` (always)
608+
* `azure-identity` (only if you plan to use Managed Identity)
609+
610+
> The worker creates clients via reflection, so it relies on whatever Storage/Identity libraries you ship with the function.
611+
612+
### Authoring – it looks just like a normal binding
613+
614+
```java
615+
@FunctionName("processBlob")
616+
public void run(
617+
@BlobTrigger(
618+
name = "content",
619+
path = "images/{name}",
620+
connection = "MyStorage") BlobClient blob,
621+
@BindingName("name") String file,
622+
ExecutionContext ctx)
623+
{
624+
ctx.getLogger().info("Size = " + blob.getProperties().getBlobSize());
625+
}
626+
```
627+
628+
```java
629+
@FunctionName("containerOps")
630+
public void run(
631+
@BlobTrigger(
632+
name = "content",
633+
path = "images/{name}",
634+
connection = "MyStorage") BlobContainerClient container,
635+
ExecutionContext ctx)
636+
{
637+
container.listBlobs()
638+
.forEach(b -> ctx.getLogger().info(b.getName()));
639+
}
640+
```
641+
642+
* `dataType` on **@BlobTrigger** is **ignored** when you bind to an SDK-type.
643+
* `connection` can be a connection string **or** an identity-based prefix – both work with SDK-types.
644+
645+
### What happens under the hood (in one minute)
646+
647+
1. **Build:** the Maven plug-in scans your methods. If it sees `BlobClient` or `BlobContainerClient` it writes `"supportsDeferredBinding": true` into `function.json`.
648+
2. **Startup:** the worker notices the flag and inserts **SdkTypeMiddleware** before your function executes.
649+
3. **Invocation:** for each SDK-typed parameter the middleware
650+
651+
* reads the binding metadata,
652+
* looks in the **WorkerObjectCache**; if no entry exists it uses reflection to construct the client,
653+
* injects the client into the argument list.
654+
655+
The cache key is derived from container name + blob name (or just container, for `BlobContainerClient`) plus the connection prefix. Thus identical invocations reuse one client; distinct blobs get their own.
656+
657+
658+
### Managed Identity
659+
660+
SDK-types honor the same identity-based connection settings you already use with classic bindings.
661+
Simply point `connection` to an MI prefix and add `azure-identity` to your function’s dependencies – the worker will build `DefaultAzureCredential` reflectively.
662+
(No additional steps are required in the worker.)
663+
664+
### Troubleshooting
665+
666+
| Exception | Meaning |
667+
| -------------------------- | ---------------------------------------------------------------------------------------------------------------- |
668+
| `SdkAnalysisException` | Build plug-in couldn’t create metadata (duplicate SDK-types in one signature, unsupported parameter type, etc.). |
669+
| `SdkRegistryException` | Runtime doesn’t recognize the stored FQCN – probably mismatched library versions. |
670+
| `SdkHydrationException` | Middleware failed to build the SDK client (missing env-vars, reflection error, credential failure). |
671+
| `SdkTypeCreationException` | Factory couldn’t turn metadata into the final SDK-type (usually casting issues). |
672+
673+
Check the inner message for the exact cause; most issues are mis-spelled environment variables or missing dependencies.
674+
675+
### Future work
676+
677+
This is the **first** SDK-type preview. We plan to:
678+
679+
* Add more Storage client types, then branch into Cosmos DB, Event Hubs, etc.
680+
* Promote the feature to General Availability once telemetry shows it’s solid.
681+
682+
Give it a try in a test function app and tell us how much faster your blob processing becomes!
683+
684+
580685
## host.json properties
581686

582687
The [host.json](functions-host-json.md#blobs) file contains settings that control blob trigger behavior. See the [host.json settings](functions-bindings-storage-blob.md#hostjson-settings) section for details regarding available settings.

0 commit comments

Comments
 (0)