{"id":773,"date":"2024-02-13T07:33:56","date_gmt":"2024-02-13T06:33:56","guid":{"rendered":"https:\/\/www.server1.dk\/?p=773"},"modified":"2024-02-13T07:33:56","modified_gmt":"2024-02-13T06:33:56","slug":"azure-function-that-returns-http-status-code-and-text-string","status":"publish","type":"post","link":"http:\/\/www.server1.dk\/?p=773","title":{"rendered":"Azure function that returns HTTP status code and text string"},"content":{"rendered":"\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">using namespace System.Net\n\n# Input bindings are passed in via param block.\nparam($Request, $TriggerMetadata)\n$body = \"&lt;html>&lt;body>\"\n\n# Write to the Azure Functions log stream.\nWrite-Host \"PowerShell HTTP trigger function processed a request.\"\n\n# Interact with query parameters or the body of the request.\n$InputString += $Request.Query.TextString\nif ($InputString -eq $null) {$InputString = \"Default string\"}\n$body += $InputString\n\n$body += \"&lt;br>&lt;p>Version: 11&lt;\/p>\"\n$body += \"&lt;\/body>&lt;\/html>\"\n\n$statusCode = $Request.Query.StatusCode\nif ($statusCode -eq $null) {$statusCode = \"OK\"}\n\n# Associate values to output bindings by calling 'Push-OutputBinding'.\nPush-OutputBinding -Name Response -Value ([HttpResponseContext]@{\n    StatusCode = [HttpStatusCode]::$statusCode\n    ContentType = \"text\/html\"\n    Body = $body\n})<\/pre>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[72,140,10],"class_list":["post-773","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-azure","tag-azure-function","tag-powershell"],"_links":{"self":[{"href":"http:\/\/www.server1.dk\/index.php?rest_route=\/wp\/v2\/posts\/773","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.server1.dk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.server1.dk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.server1.dk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.server1.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=773"}],"version-history":[{"count":1,"href":"http:\/\/www.server1.dk\/index.php?rest_route=\/wp\/v2\/posts\/773\/revisions"}],"predecessor-version":[{"id":774,"href":"http:\/\/www.server1.dk\/index.php?rest_route=\/wp\/v2\/posts\/773\/revisions\/774"}],"wp:attachment":[{"href":"http:\/\/www.server1.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=773"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.server1.dk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=773"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.server1.dk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=773"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}