I've created a blob trigger that accepts a file from a blob, unzips it and moves it to another blob using streams.
My code looks like this
[FunctionName("Requests")]
[StorageAccount("samplecontainer")]
public static void Run([BlobTrigger("incoming/{name}")]Stream myBlob,
[Blob("processing/{name}.xml", FileAccess.Write)] TextWriter output,
string name, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
string returnValue;
using (Stream blob = myBlob)
{
using (GZipStream decompressionStream = new GZipStream(blob, CompressionMode.Decompress))
{
log.LogInformation($"Unzipping file");
name = name.Replace(".gz", "");
var content = String.Empty;
using (StreamReader reader = new StreamReader(decompressionStream))
{
content = reader.ReadToEnd();
reader.Close();
}
returnValue = content;
}
}
log.LogInformation($"C# Blob trigger function finished processing blob\n Name:{name} \n Now writing to xml");
output.WriteLine(returnValue);
}
This will in fact work while running this locally using "AzureWebJobsStorage": "UseDevelopmentStorage=true" in my local.settings.json file.
However, once I've deployed this app and upload a file to the real container using Azure Storage Explorer nothing happens and the activity log shows that the operation failed in Write.Tiny.txt.gz, Could not find file 'D:\home\site\wwwroot\Requests\tiny.txt.gz'.
I have http triggers that do work, and I have tried turning off the configuration WEBSITE_RUN_FROM_PACKAGE to no effect. Am I maybe missing some setting or config? When I console into this path in the function app and cat the function.json I get this:
{
"generatedBy": "Microsoft.NET.Sdk.Functions-1.0.29",
"configurationSource": "attributes",
"bindings": [
{
"type": "blobTrigger",
"connection": "samplecontainer",
"path": "incoming/{name}",
"name": "myBlob"
}
],
"disabled": false,
"scriptFile": "../bin/azure-functions.dll",
"entryPoint": "Requests.Run"
}