Reputation: 3294
I have a working .NET6 in-proc Azure Function. I'm in the process of converting it to an isolated worker process (out-of-proc) .net7 function.
I have a HttpTrigger function that should get a file from the blob-storage. Since the blob-storage is case-sensitive and all files are saved in upper-case, I need to make the input upper-case as well.
With the in-proc function, I did that by injecting Microsoft.Azure.WebJobs.IBinder binder
and then use binder.BindAsync<byte[]>(new Microsoft.Azure.WebJobs.BlobAttribute($"%BlobContainerName%/{fooUpper}", FileAccess.Read)
This is the .net6 in-proc function:
[Function(nameof(GetFile))]
public async Task<IActionResult> GetFile(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "bar/{foo}")] HttpRequest req,
Microsoft.Azure.WebJobs.IBinder binder, Microsoft.Azure.WebJobs.ExecutionContext context, string foo)
{
// The file name is always upper-case:
var fooUpper = foo.ToUpperInvariant();
var blobStream = await binder.BindAsync<byte[]>(
new Microsoft.Azure.WebJobs.BlobAttribute($"%BlobContainerName%/{fooUpper}", FileAccess.Read),
req.FunctionContext.CancellationToken).ConfigureAwait(false);
return await ExecuteAsync(fooUpper, context.FunctionDirectory, blobStream,
req.FunctionContext.CancellationToken)
.ConfigureAwait(false);
}
Of course, I tried migrating this function to a .net7 isolated function by replacing HttpRequest req
with HttpRequestData req
and it compiles but when I run it binder
is always null
.
What is the isolated function version of my function?
Please advice.
Upvotes: 1
Views: 1673
Reputation: 8694
Check if my below findings helpful to fix your issue:
BlobContainerClient is no longer working in isolated mode
AFAIK, BlobContainerClient
should work with the .NET Isolated Process Version 7 in Azure Functions using Azure.Storage.Blobs
NuGet Package as shown in this SO Answer #75015570 by the user @HariKrishna and MS DOC.
If you use the NuGet Package Azure.Storage.Blobs
, you can initialize the BlobContainerClient
class-objects which is compatible in .NET Isolated Process and for working with the Blob Container Objects, you have to initialize the BlobServiceClient for Connecting to Storage Account and getting access to the Blob Container.
public HttpResponseData Run([Microsoft.Azure.Functions.Worker.HttpTrigger(AuthorizationLevel.Function, "get", Route = "bar/{foo}")] HttpRequestData req,
BlobContainerClient blobContainerClient, IBinder binder, ExecutionContext executionContext)
Here is the GitHub Article on Azure Functions .NET Isolated Process of using the Ibinder input parameter for data binding and there are some examples provided in the same article for working in the context of Ibinder and StorageAccountAttribute such as Microsoft.Azure.WebJobs.BlobAttribute
.
Upvotes: 1