Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I call function from one csx file to another csx file in Azure?

How can we create another run.csx and call the existing function from one csx file to another in an Azure Function App?

like image 813
Mayank Agrawal Avatar asked Jul 28 '16 22:07

Mayank Agrawal


1 Answers

You can just write another file, e.g. lib.csx and load it via #load "lib.csx" in your main script file. See here for the docs

As an example, place this into your run.csx

#load "lib.csx"

using System;

public static void Run(TimerInfo myTimer, TraceWriter log)
{
    log.Info($"C# Timer trigger function executed at: {DateTime.Now}");    
    log.Info(doubleTheInt(5).ToString());
}

and that into a lib.csx

using System;

public static int doubleTheInt(int x) {
    return x+x;
}

and it should output 10 in the log

like image 173
DAXaholic Avatar answered Oct 23 '22 20:10

DAXaholic