An input binding lets an Azure Function receive data from an external resource without writing all the connection plumbing yourself. For Blob Storage, it maps a blob path such as originalnfts/{nftid} to a readable stream. section 8.2.2
Resize an NFT without touching the original
A ProcessNFT HTTP-triggered function reads an image from originalnfts/{nftid}, resizes it, and writes the result to copynfts/{nftid}. FileAccess.Read protects the source; a separate output binding uses FileAccess.Write. With Azurite and VS Code, place an image in the container, run the function locally, and call /api/nft/{nftid}. section 8.2.2
[FunctionName("ProcessNFT")]
public static void Run(
[HttpTrigger(AuthorizationLevel.Anonymous,
"get", "post", Route = "nft/{nftid}")] HttpRequest req, #1
[Blob("originalnfts/{nftid}", FileAccess.Read)]
Stream nftImage, #2
[Blob("copynfts/{nftid}", FileAccess.Write)]
Stream nftSmall) #3
{
IImageFormat format;
using (Image<Rgba32> input =
Image.Load<Rgba32>(nftImage, out format)) #4
{
input.Mutate(x => x.Resize(320, 200)); #5
input.Save(nftSmall, format); #6
}
}
The annotated function shows the route, readable Blob input stream, writable output stream, image transformation, and save operation. section 8.2.2
