Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,678 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I have the following azure function which use imperativ binding. The writer
write json data to the output stream which works fine. Instead of write json data I would rather use the same contents the exist in the input stream which is xml data.
So from the input stream I want to copy the content to the output stream.
public void Run(
[BlobTrigger("input/{name}.xml")] Stream inputBlob,
IBinder binder,
string name, ILogger log)
{
XmlDocument doc = new XmlDocument();
doc.Load(inputBlob);
string json = jsonHandling.Convert(doc);
json = jsonHandling.Clean(json);
using (var writer = binder.Bind<TextWriter>(new BlobAttribute(
$"output/a6109523-a23b-47ed-9732-40ea4535c82f {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")}.json", FileAccess.Write)))
{
writer.Write(json);
};
}
Many thanks in advance
Tony Johansson
I have added a sample code please check if it works for you
if not I can work on this in more detail
public void Run(
[BlobTrigger("input/{name}.xml")] Stream inputBlob,
IBinder binder,
string name, ILogger log)
{
using (var outputBlob = binder.Bind<Stream>(new BlobAttribute(
$"output/a6109523-a23b-47ed-9732-40ea4535c82f {DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss")}.xml", FileAccess.Write)))
{
inputBlob.CopyTo(outputBlob);
};
}