Azure Functions is a powerful tool that can be used to automate tasks and processes. In this article, we will show you how to use Azure Functions to automate your workflows. What is Azure Functions? Azure Functions is a cloud-based platform that allows you to create custom functions using the Microsoft Azure platform. You can use these functions to automate your workflows or process flows. How do I create a function? To create a function, first sign in to your account at azure.com and click on the Functions icon in the upper-left corner of the page. From here, you can select the Create Function button. This will take you to the Function Creation wizard where you can enter basic information about your function. The following are some of the fields that you will need to enter: Name: This is the name of your function. This is the name of your function. Description: This is a brief description of your function. This is a brief description of your function. Type: This determines how your function will be used (e.g., webhook, API). For this example, we will use the webhook type. Note that there are other types available (such as API), but for this tutorial we will use webhooks because they are simpler and more common than APIs. You can find more information about each type here: https://azurefunctionsplatformdocs.microsoftazurecom/en-us/articles/types-of-functions/. After entering these fields, click on Next > . On the next page, you will need to select an account from which your functions will run (this account must have an active subscription). After selecting an account, click on Next > . On the final page of this wizard, you will need to provide details about how your function should run (this information depends on what type of function it is). For our example, we will simply enter ..


In recent years, serverless has become one of the most talked-about technologies. Though not truly serverless, serverless options abstract the management away from the user to a managed and hosted service.

One of the most exciting abilities is that of writing code to then run on serverless instances. Azure Functions offers several runtimes, languages, and even Docker container support. You merely pick the language you want to write in, deploy the code, and consume the results.

Provisioning Azure Function App

First, navigate to “Function App” within the Azure Portal. Once there, click on the “Create Function App” button.

Enter in the values that make the most sense for your environment and needs. In this example, we are going to use the PowerShell Core 7.0 runtime.

Function App name: lc-test-function Publish: Code Runtime stack: PowerShell Core Version: 7. 0 Region: East US

On the Hosting tab, we are going to create a new storage account to hold the output data from the function. Because this is PowerShell, the runtime only supports Windows, despite PowerShell 7 being cross-platform. Finally, we are using the Consumption plan for this Azure Function.

For Monitoring, we are going to create a new Application Insights configuration and enable the Monitoring option.

We are going to skip tagging in this article, and move on to Review & Create. Once here, verify that everything looks accurate, then click on “Create.”

Creating Azure Function Code

For this article, we are going to demonstrate how this works with an HTTP trigger function. Navigate to your App Function and click on the “Functions” pane. Once there, click on “Add” and choose the HTTP trigger template.

We are going to stick with the default values for the function name and the Authorization Level. The different levels for authorization correspond to the following:

Function: Uses a specific function key Admin: Uses the master key for the environment Anonymous: Needs no authorization, limits capabilities

Modifying Function Code

Click on the newly created function HttpTrigger1, and click on the “Code + Test” section. Here you will find an inline code editor that will allow you to test and run your function code. The values below are the default configurations.

So, what can you do with Function Apps? There are many uses, and to demonstrate one of them, we are going to pass in a specific location ID from an invoking PowerShell call, which in turn will call the Azure Function to run against a REST API to get Weather data. The modifications we are making to the default configuration are:

Modify $name to $location Create an Invoke-RestMethod call to the metaweather. com API Format results to be sent as a string in the body

Click “Save” to make the changes. We will Test/Run this code to verify that it works as expected. Once you click on “Test/Run,” we will be presented with a window that allows us to modify the input to correspond to what the code expects.

After running the code, you can see the correct output in the Output tab under the HTTP response content.

Triggering the Function via External PowerShell

First, click on the “Get Function” URL button, which will present you with an URL that you can use to call the Function app.

In a PowerShell session, use the Invoke-RestMethod function to call the HTTP trigger and pass in the location variable that the script is expecting. As you can see from the output, the weather data is returned as expected.

Conclusion

Azure Functions is a powerful tool to create serverless functions in several languages. By freeing up a developer to not have to focus on the environment and all of the dependencies, they can quickly iterate on code and design to create unique functionality!