mintorii
mintorii

Reputation: 49

Call a python scripts alternatively to kusto

I have seen an instruction on Microsoft docs that we pack the python script of code as :

let code = ''' if 1:
    *...*
'''
table_name
| evaluate python(typeof(*),code,...)

But i would like to ask, is there anyway which allow us to call a python file .py, .ipynb directly into a kusto. I plan to upload the script of code from local to Azure portal container or something like that. I'd appreciate for any help or suggestions from you guys, thanks a lot.

Upvotes: 1

Views: 604

Answers (1)

Yoni L.
Yoni L.

Reputation: 25895

You can use the externaldata operator to read the contents of a script you've uploaded to blob storage.

There's an example for doing so here: https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/pythonplugin?pivots=azuredataexplorer#usage-tips

let script = 
    externaldata(script:string)
    [h'https://kustoscriptsamples.blob.core.windows.net/samples/python/sample_script.py']
    with(format = raw);
range x from 1 to 360 step 1
| evaluate python(
    typeof(*, fx:double),
    toscalar(script), 
    pack('gain', 100, 'cycles', 4))
| render linechart

Upvotes: 2

Related Questions