Created
October 15, 2017 23:07
-
-
Save pratapprashant/4540d9b2dd26fdfb323b72ebca92da3c to your computer and use it in GitHub Desktop.
Calling AI APIs from Azure FunctionApp (PowerShell)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# POST method: $req | |
$requestBody = Get-Content $req -Raw | ConvertFrom-Json | |
$name = $requestBody.name | |
$instrumentationKey = "<ai key>" | |
$aiClient = New-Object "Microsoft.ApplicationInsights.TelemetryClient" | |
$aiClient.InstrumentationKey = $instrumentationKey | |
$aiClient.TrackPageView("my pageview") | |
#$aiClient.TrackEvent("my event") | |
$aiClient.TrackTrace("my trace") | |
$aiClient.TrackMetric("my metric", 20.0) | |
$now = Get-Date | |
$aiClient.TrackDependency("my dependency", "my call", $now, 10, 1) | |
$aiClient.Flush() | |
# GET method: each querystring parameter is its own variable | |
if ($req_query_name) | |
{ | |
$name = $req_query_name | |
} | |
Out-File -Encoding Ascii -FilePath $res -inputObject "Hello $name" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment