I believe both of the implementation gives same performance.
Yes! As Skin Said, Microsoft suggests you avoid hardcoding access to the integration services with Azure Functions.
Scenarios like when the Function is receiving or sending the data (queue message), you can use the Function Parameters for receiving data and return value of the function for sending data.
One of the practical examples, I come to know the difference and usage of this bindings and hardcode in the Azure functions from Pluralsight course is:
Here in below code, I took Blob output binding the Function level:
public class GenerateLicenseFile
{
[FunctionName("GenerateLicenseFile")]
public void Run([QueueTrigger("orders", Connection = "AzureWebJobsStorage")]Order order,
[Blob("licenses/{rand-guid}.lic")]TextWriter outputBlob,
ILogger log)
{
outputBlob.WriteLine($"OrderId: {order.OrderId}");
outputBlob.WriteLine($"Email: {order.Email}");
outputBlob.WriteLine($"ProductId: {order.ProductId}");
outputBlob.WriteLine($"PurchaseDate: {DateTime.UtcNow}");
To bring the Order Id as the license File name,
public static class GenerateLicenseFile
{
[FunctionName("GenerateLicenseFile")]
public static async Task Run(
[QueueTrigger("orders", Connection = "AzureWebJobsStorage")] Order order,
IBinder binder,
ILogger log)
{
var outputBlob = await binder.BindAsync<TextWriter>(
new BlobAttribute($"licenses/{order.OrderId}.lic")
{
Connection = "AzureWebJobsStorage"
});
outputBlob.WriteLine($"OrderId: {order.OrderId}");
outputBlob.WriteLine($"Email: {order.Email}");
outputBlob.WriteLine($"ProductId: {order.ProductId}");
outputBlob.WriteLine($"PurchaseDate: {DateTime.UtcNow}");
There are some scenarios mentioned when to use bindings as parameters and hardcode in the Azure Functions, please refer this Microsoft Documentation for more information.