Reputation: 3142
I have created two storage accounts, one have my azure function while another is a file storage account. What I want is to create a file from azure function and store it in my azure file storage. I went through official documentation of file storage as well as of Azure function, but I am not finding any connecting link between the two.
Is it possible to create file from azure function and store it in file storage account, if yes, please assist accordingly.
Upvotes: 2
Views: 5512
Reputation: 35134
There is a preview of Azure Functions External File bindings to upload file to external storage, but it doesn't work with Azure File Storage. There is a github issue to create a new type of binding for Files.
Meanwhile, you can upload the file just by using Azure Storage SDK directly. Something like
#r "Microsoft.WindowsAzure.Storage"
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.File;
public static void Run(string input)
{
var storageAccount = CloudStorageAccount.Parse("...");
var fileClient = storageAccount.CreateCloudFileClient();
var share = fileClient.GetShareReference("...");
var rootDir = share.GetRootDirectoryReference();
var sampleDir = rootDir.GetDirectoryReference("MyFolder");
var fileToCreate = sampleDir.GetFileReference("output.txt");
fileToCreate.UploadText("Hello " + input);
}
Upvotes: 3