Skip to content

Commit c6a820e

Browse files
committed
Merge remote-tracking branch 'ahmed/patch-1' into fixup
2 parents 8610a23 + a429b01 commit c6a820e

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

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

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,130 @@ Because the blob trigger uses a queue internally, the maximum number of concurre
583583

584584
Limits apply separately to each function that uses a blob trigger.
585585

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

588712
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)