Azure function .net 5 Isolated blob output binding

vijay moorthy 1 Reputation point
2021-07-31T08:44:22.09+00:00

am trying to create a Blob in the 'test ' container. In old version,i.e Azure function 3.1, I was using out parameter and UploadFromStreamAsync() . However, in new version , there is not parameter.

I am getting error message , Server not found Internal server error 500.

Can someone guide me ?

The code below

namespace FunctionBlobOut
{
public static class Function1
{

[Function("BlobOut")]
[BlobOutput("test")]
public static async Task<MemoryStream>
Run([HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequestData req,
FunctionContext executionContext)
{
try
{
using (MemoryStream ms = new MemoryStream())
{
await req.Body.CopyToAsync(ms);
return ms;
}
}
catch (System.Exception exp)
{
return null;
}
}
}

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,213 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,641 Reputation points Microsoft Employee
    2021-08-02T04:22:24.18+00:00

    @vijay moorthy Since you have a HTTP Trigger, you would have multiple output bindings which need to be returned in an object from the function as shown in the docs. Here is the code snippet from the docs for reference.

       public static class MultiOutput  
       {  
           [Function("MultiOutput")]  
           public static MyOutputType Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequestData req,  
               FunctionContext context)  
           {  
               var response = req.CreateResponse(HttpStatusCode.OK);  
               response.WriteString("Success!");  
         
               string myQueueOutput = "some output";  
         
               return new MyOutputType()  
               {  
                   Name = myQueueOutput,  
                   HttpResponse = response  
               };  
           }  
       }  
         
       public class MyOutputType  
       {  
           [QueueOutput("myQueue")]  
           public string Name { get; set; }  
         
           public HttpResponseData HttpResponse { get; set; }  
       }  
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.