0

I am having an issue with upgrading a repo to .NET 8. The issue is with an Azure HttpTrigger function that outputs to blob storage. I did notice that when I used the upgrade tool in Visual Studio to upgrade the function from .NET 6 to .NET 8 it did change the blob function name from Blob() to BlobInput(), which I believe is not right because I am outputting to blob.

In the .NET 6 version, the function looked like this:

enter image description here

In searching the web, I found that I needed to install the Microsoft.Azure.Functions.Worker.Extensions.Storage package (I'm running dotnet-isolated).

I'm assuming that I need to change the Blob() to BlobOutput() which only has a path parameter, so I need to define the connection in another way. Possibly defining it within the program.cs file or some sort of injection in the function itself?

If someone could point me in the right direction, I'd appreciate it! Let me know if you need to see anything else. Thanks!

2
  • 1
    Provide your code in text format. Commented Dec 21, 2024 at 3:30
  • You can use [BlobOutput("container/{name}-output.txt", Connection = "AzureWebJobsStorage")] Commented Dec 21, 2024 at 5:08

1 Answer 1

0

Use BlobOutput() to implement HTTP Trigger Isolated Azure function output binding that outputs to blob storage.

 [BlobOutput("Container/{name}-output.txt", Connection = "AzureWebJobsStorage")]

I have created a sample .NET 8.0 isolated Azure function to implement output binding.

Code snippet:

public class Function1
{
     private readonly ILogger<Function1> _logger;

     public Function1(ILogger<Function1> logger)
     {
         _logger = logger;
     }

     [Function("Function1")]
     [BlobOutput("test-samples-output/{name}-output.txt", Connection = "AzureWebJobsStorage")]

     public IActionResult RunStyleHttpAsync([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequest req)
     {
         _logger.LogInformation("C# HTTP trigger function processed a request.");
         return new OkObjectResult("Welcome to Azure Functions!");
     }
}

local.settings.json:

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "<Storage_Connection_String>",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
  }
}

.csproj:

<ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.2.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage" Version="6.6.0" />
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
</ItemGroup>

Blob got created in the Azure Storage container as below:

enter image description here

Content of the file:

enter image description here

Console output:

Functions:

        Function1: [GET,POST] http://localhost:7194/api/Function1

For detailed output, run func with --verbose flag.
[2024-12-21T05:20:34.550Z] Executing 'Functions.Function1' (Reason='This function was programmatically called via the host APIs.', Id=4cfe55c4-fde1-4d0e-9af6-89a4b55844e5)
[2024-12-21T05:20:34.949Z] C# HTTP trigger function processed a request.
[2024-12-21T05:20:34.958Z] Executing OkObjectResult, writing value of type 'System.String'.
[2024-12-21T05:20:39.440Z] Host lock lease acquired by instance ID '000000000000000000000000F72731CC'.
[2024-12-21T05:20:40.723Z] Executed 'Functions.Function1' (Succeeded, Id=4cfe55c4-fde1-4d0e-9af6-89a4b55844e5, Duration=6217ms)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the clarification! It's working now!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.