An HTTP trigger starts a Function or workflow when its HTTP endpoint receives a request. It is useful when a caller needs to start work through an API rather than wait for an event such as a new blob. An Azure Function must have exactly one trigger; without one, it has no signal to run. section 8.2.1 section 8.4.5
For an Azure Function, the request arrives as an HttpRequest parameter. It can carry ordinary HTTP details, including the host and referrer. The HttpTrigger declaration also sets the authorization level and permitted methods: the example accepts GET and POST. Anonymous access requires no authentication, so choose it deliberately rather than by habit. section 8.2.1 section 8.2 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 Function declaration places HttpTrigger on the request parameter and uses a route containing an NFT ID. Separate Blob bindings read the original image and write the resized copy; they do not start the Function. section 8.2.2
Put a Logic App behind an API
Suppose an API call should post an NFT image. A Logic App started by a blob trigger cannot be connected to API Management as that endpoint: it needs an HTTP endpoint. Create a second Logic App with an HTTP trigger, accept the NFT ID in a query string, retrieve the image from Blob Storage, post the tweet, and connect the endpoint to API Management. Consider authentication for the incoming request, too. section 8.4.5
