Skip to content

Instantly share code, notes, and snippets.

@wsilveiranz
Created November 20, 2020 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsilveiranz/19f558a945305bfd185f9f13d3fb1115 to your computer and use it in GitHub Desktop.
Save wsilveiranz/19f558a945305bfd185f9f13d3fb1115 to your computer and use it in GitHub Desktop.
What is my IP Powershell Function
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
Write-Host "PowerShell HTTP trigger function processed a request."
$status = [HttpStatusCode]::OK
try {
$response = (Invoke-WebRequest -uri https://ifconfig.me/ip).Content
}
catch {
$status = [HttpStatusCode]::InternalServerError
$response = $_
}
# Interact with query parameters or the body of the request.
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = $status
Body = $response
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment