Azure Functions
Last updated
Last updated
Azure Functions is akin to AWS Lambda. This is a compute service that lets you run code without provisioning or managing servers. Azure Functions, essentially are short lived servers that run your function and provide you with output that can be then used in other applications or consumed by other endpoints.
We will essentially,
Setup a simple Azure Function
Execute commands within the Azure Function instance
In the Azure Portal, click on Create a resource
> Compute
> Function App
Give the Function App a name. This name needs to be unique across the Internet. You can use your unique-name to proceed.
Select Code
under Publish.
Select Runtime Stack to be .NET Core
.
Click Next: Hosting
Ensure Operating System is set to Windows
Ensure Plan type is set to Consumption
Click on Review + Create
with the rest of the settings left to default.
Click on Create
once the Function settings have been reviewed
A notification alert will let us know if the Function was deployed. Click on Go to resource
when the notification comes up.
To see notifications you can also go to Activity Log
and check if your Function has been setup
In the Function window click on the + icon next to Functions and click In-portal
.
Click Continue
and select Webhook+API
in the next window and click Create
The default code is a 'Hello, World' function. Click on </> Get function URL
and copy the URL from the modal window.
Navigate to the URL and pass a name=Test
GET parameter at the end of the URL to execute the Function.
Replace the code in run.csx
with the following code:
Navigate to the Function URL and pass cmd=dir C:\
Note: The Azure Functions dashboard also provides a console that you can use to Interact with the OS directly. A different system user executes commands in the console then the one that executes through the HTTP Trigger.
The following commands are standard Windows commands that would work across Windows versions and can be used to obtain additional info about the system on which we have gained access. These commands can be used for our Azure Function as well.
Who are you on the system: whoami
What privileges do you have within the Azure Function: whoami /priv
What operating system is it?: systeminfo
What is the current directory and its contents?: dir
Think of other commands to run, essentially you are trying to get an understanding of the environment.