Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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://docs.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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading