Last active
April 16, 2016 15:17
-
-
Save Sam-Martin/f97c34491a2d5b58e2c0d5d3ff2b7415 to your computer and use it in GitHub Desktop.
An example of how to create a PowerShell based HTTP request based Azure Function
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
# Get input and output params (as named in our function.json) | |
$result = $Env:res | |
$requestPath = $env:req | |
$executionPath = Split-Path -parent $PSCommandPath | |
$tempPath = Split-Path -parent $env:req | |
# Read the input from file and parse it to an object | |
[Console]::WriteLine("Reading input from $env:req") | |
$requestObj = get-content $requestPath | out-string | convertfrom-json | |
# Manipulate our input a bit to create an output string | |
$output = "Hello {0} {1}" -f $requestObj.FirstName, $requestObj.LastName | |
# Let's try writing it to a file, because we can! | |
$filePath = "$env:temp\test.txt" | |
Set-Content $filePath -Value $output | |
[Console]::WriteLine("Reading data from $filePath `r`n`t'$(get-content $filePath)'") | |
# Finally let's output it | |
$output | Out-File -Encoding Ascii $result |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example execution: