Thursday, 8 September 2022

Python - Get invocation id in azure function

After finding the right part in the documentation it was surprisingly easy:

def main(mytimer: func.TimerRequest, context: func.Context) -> None:
    try: 
        invocation_id = context.invocation_id
        # Function continues here. 

    except Exception as e:
        logging.error("Main program failed with error: " + str(e)) 

Be aware that this solution only works if func.Context is assigned to context. Using any other name than context results in errors for me -.- 


from: https://stackoverflow.com/questions/64521460/get-current-invocationid-or-operation-id

Thursday, 2 September 2021

Analyze Kusto query

 .show queries | where ClientActivityId in ("{OldKQLClientActivityId}""{NewKQLClientActivityId}");

Friday, 13 August 2021

How to find an item in a json array using kusto

you could use mv-expand or mv-apply:

print d = dynamic([
  {
    "Key": "key0",
    "Value": 0
  },
  {
    "Key": "key1",
    "Value": 2
  }
])
| mv-apply d on (
    where d.Key == "key0"
    | project d.Value 

) 


from: https://stackoverflow.com/questions/59370390/how-to-find-an-item-in-a-json-array-using-kusto

Tuesday, 29 June 2021

.show ingestion mapping

 .show table MyTable ingestion csv mapping "Mapping1"

.show table MyTable ingestion csv mappings .show table MyTable ingestion mappings .show database MyDatabase ingestion csv mappings


from: https://docs.microsoft.com/en-us/azure/data-explorer/kusto/management/show-ingestion-mapping-command

Monday, 14 June 2021

Use wildcard to search Kusto database

 find in (database('db_name_*').table_name_*_test) where isnotempty(['col1'])
| where time >= datetime(2021-05-05T00:00:00.00Z)
| where ['col1'] has "keyword"
| project ['col1']
| limit 500
| order by time desc

Thursday, 18 February 2021

Show all databases row count

 

.show databases details
| project DatabaseName, TotalSize
| order by TotalSize desc

Thursday, 24 September 2020

Kusto convert unix timestamp to datetime format

 

Example: Unix time

Unix time (also known as POSIX time or UNIX Epoch time) is a system for describing a point in time as the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC), minus leap seconds.

If your data includes representation of Unix time as an integer, or you require converting to it, the following functions are available:

Kusto
let fromUnixTime = (t:long)
{ 
    datetime(1970-01-01) + t * 1sec 
};
print result = fromUnixTime(1546897531)
EXAMPLE: UNIX TIME
result
2019-01-07 21:45:31.0000000
Kusto
let toUnixTime = (dt:datetime) 
{ 
    (dt - datetime(1970-01-01)) / 1s 
};
print result = toUnixTime(datetime(2019-01-07 21:45:31.0000000))
TABLE 2
result
1546897531


from : https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/datetime-timespan-arithmetic

Python - Get invocation id in azure function

After finding the  right part in the documentation  it was surprisingly easy: def main ( mytimer: func.TimerRequest, context: func.Context ...