This assumes an understanding of Github and Azure Functions. There are plenty of resources out there explaining that better than I can.
Github
Create a fresh repository and create a file, host.json, in the root:
{ "functions" : [ "HelloAzureFunctions" ], "id": "ed5d78e575e14f0481c899532d41f5c0" }
Now create a folder called HelloAzureFunctions. Inside that create a file, function.json:
{ "bindings": [ { "type": "httpTrigger", "name": "req", "direction": "in", "methods": [ "get" ] }, { "type": "http", "name": "res", "direction": "out" } ] }
And in this case we will use PowerShell; we need a file called run.ps1:
$requestBody = Get-Content $req -Raw | ConvertFrom-Json $name = $requestBody.name if ($req_query_name) { $name = $req_query_name } Out-File -Encoding Ascii -FilePath $res -inputObject "Hello, $name"
You can fork my repository if you like, https://github.com/spaelling/hello-azure-functions. There is also a a PowerShell script there that can be used for testing (you can just paste in the webhook URI in a browser if you rather like that).
Also keep your webhooks a secret. In the aforementioned script I show how to get the webhook URI from an Azure Key Vault.
Ingen kommentarer:
Send en kommentar
Bemærk! Kun medlemmer af denne blog kan sende kommentarer.