Blob storage bindings
Azure Functions provides seamless integration with Azure Blob storage using input and output bindings. This page explains how to work with blobs in your functions.
Input binding
Read the content of a blob as a string
, byte[]
, Stream
, or a custom POCO.
{
"type": "blob",
"direction": "in",
"name": "inputBlob",
"path": "samples/{name}",
"connection": "AzureWebJobsStorage"
}
Example (C#):
public static void Run(
[BlobTrigger("samples/{name}", Connection = "AzureWebJobsStorage")] Stream myBlob,
string name,
ILogger log)
{
using var reader = new StreamReader(myBlob);
var content = reader.ReadToEnd();
log.LogInformation($"Blob {name} contents: {content}");
}
Output binding
Write data to a blob as part of the function execution.
{
"type": "blob",
"direction": "out",
"name": "outputBlob",
"path": "output/{name}",
"connection": "AzureWebJobsStorage"
}
Example (JavaScript):
module.exports = async function (context, req) {
const name = req.query.name || (req.body && req.body.name);
if (name) {
context.bindings.outputBlob = `Hello ${name}!`;
context.res = { status: 200, body: "Blob written." };
} else {
context.res = { status: 400, body: "Please provide a name." };
}
};
Binding attributes per language
Language | Input attribute | Output attribute |
---|---|---|
C# | [BlobTrigger] | [Blob] |
JavaScript | context.bindings.inputBlob | context.bindings.outputBlob |
Python | inputblob: func.InputStream | outputblob: func.Out[str] |
PowerShell | $TriggerInput | $OutputBlob |
Best practices
- Use
Path
patterns with bindings to categorize blobs. - Prefer streaming (
Stream
) for large blobs to avoid memory pressure. - Leverage
BlobTrigger
for event‑driven processing. - Set
Connection
to a Managed Identity connection string for secure access.