DEV Community

kemurayama
kemurayama

Posted on

When you want to create a new blob in your code Azure Functions

You can create a new blob file by writing like below.
Plus {rand-guid} generate guid. It is useful !!

Storage Account Setting is set by Storage Account Attribute.

[FunctionName("MyTestFuncion")]
[StorageAccount("StorageConnectionAppSetting")]

public static async Task Run([EventHubTrigger("myeh", Connection = "EHConnection")] EventData[] events,
        Binder binder,
        ILogger log)
    ...

    using (var writer = await binder.BindAsync<TextWriter>(
                        new BlobAttribute("<container>/{rand-guid}.json")))
                    {
                        writer.Write(<what you want to write>);
                    }
Enter fullscreen mode Exit fullscreen mode

Top comments (0)