Skip to content

Commit f9de407

Browse files
committed
fixup examples
1 parent c5902cf commit f9de407

File tree

2 files changed

+57
-3
lines changed

2 files changed

+57
-3
lines changed

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

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,56 @@ public void run(
8484
}
8585
```
8686

87-
This example
87+
This [SDK types example](./functions-reference-java.md#sdk-types) uses `BlobClient` to access properties of the blob.
88+
89+
```java
90+
@FunctionName("processBlob")
91+
public void run(
92+
@BlobTrigger(
93+
name = "content",
94+
path = "images/{name}",
95+
connection = "AzureWebJobsStorage") BlobClient blob,
96+
@BindingName("name") String file,
97+
ExecutionContext ctx)
98+
{
99+
ctx.getLogger().info("Size = " + blob.getProperties().getBlobSize());
100+
}
101+
```
102+
103+
This [SDK types example](./functions-reference-java.md#sdk-types) uses `BlobContainerClient` to access info about blobs in the container that triggered the function.
104+
105+
```java
106+
@FunctionName("containerOps")
107+
public void run(
108+
@BlobTrigger(
109+
name = "content",
110+
path = "images/{name}",
111+
connection = "AzureWebJobsStorage") BlobContainerClient container,
112+
ExecutionContext ctx)
113+
{
114+
container.listBlobs()
115+
.forEach(b -> ctx.getLogger().info(b.getName()));
116+
}
117+
```
118+
119+
This [SDK types example](./functions-reference-java.md#sdk-types) uses `BlobClient` to get information from the input binding about the blob that triggered the execution.
120+
121+
```java
122+
@FunctionName("checkAgainstInputBlob")
123+
public void run(
124+
@BlobInput(
125+
name = "inputBlob",
126+
path = "inputContainer/input.txt") BlobClient inputBlob,
127+
@BlobTrigger(
128+
name = "content",
129+
path = "images/{name}",
130+
connection = "AzureWebJobsStorage",
131+
dataType = "string") String triggerBlob,
132+
ExecutionContext ctx)
133+
{
134+
ctx.getLogger().info("Size = " + inputBlob.getProperties().getBlobSize());
135+
}
136+
```
88137

89138
::: zone-end
90139
::: zone pivot="programming-language-typescript"

articles/azure-functions/functions-reference-java.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ Bind binary inputs or outputs to `byte[]`, by setting the `dataType` field in yo
295295

296296
If you expect null values, use `Optional<T>`.
297297

298-
### SDK types (preview)
298+
### <a name="sdk-types"></a>SDK types (preview)
299299

300300
You can currently use these native SDK types in your bindings:
301301

@@ -315,6 +315,8 @@ When you use these native SDK types, your functions can use client types to acce
315315

316316
#### Examples
317317

318+
Blob trigger that uses `BlobClient` to access properties of the blob.
319+
318320
```java
319321
@FunctionName("processBlob")
320322
public void run(
@@ -329,6 +331,8 @@ public void run(
329331
}
330332
```
331333

334+
Blob trigger that uses `BlobContainerClient` to access info about blobs in the container.
335+
332336
```java
333337
@FunctionName("containerOps")
334338
public void run(
@@ -343,6 +347,7 @@ public void run(
343347
}
344348
```
345349

350+
Blob input binding that uses `BlobClient` to get information about the blob that triggered the execution.
346351

347352
```java
348353
@FunctionName("checkAgainstInputBlob")
@@ -364,7 +369,7 @@ public void run(
364369
#### Considerations
365370

366371
+ The `dataType` setting on `@BlobTrigger` is ignored when binding to an SDK type.
367-
+ Currently, only one SDK type can be used at a time in a given function definition. If your function has both a Blog trigger or Input binding and a Blob output binding, one binding can use an SDK type (such as `BlobClient`) and the others must use a native type or POJO.
372+
+ Currently, only one SDK type can be used at a time in a given function definition. When a function has both a Blog trigger or input binding and a Blob output binding, one binding can use an SDK type (such as `BlobClient`) and the others must use a native type or POJO.
368373
+ You can use managed identities with SDK types.
369374

370375
#### Troubleshooting

0 commit comments

Comments
 (0)