If you are looking to run small pieces of code or background tasks without worrying about underlying application infrastructure, Azure Functions is the perfect serverless solution.
In this tutorial, we will walk through the step-by-step process of creating a Function App using the Azure Portal, specifically utilizing a PowerShell runtime on a Consumption plan. Let’s get started!
Table of Contents
- Prerequisites
- Step 1: Navigate to Function Apps
- Step 2: Choose a Hosting Plan
- Step 3: Configure Basic Details
- Step 4: Storage and Monitoring
- Step 5: Review and Create
- Step 6: Create an HTTP Trigger Function
- Conclusion
Prerequisites
Before you begin, ensure you have an active Azure Subscription.
Step 1: Navigate to Function Apps
- Sign in to your Azure Portal.
- In the top search bar, type in “Function App” and select it from the services list.
- Click on the Create button to start provisioning your new resource.
Step 2: Choose a Hosting Plan
Azure provides multiple hosting plans depending on your scaling, network, and performance needs (such as Flex Consumption, Functions Premium, and App Service).
For this demo, we will choose the Consumption (Windows) plan. This is a pay-as-you-go serverless model where you are only billed when your functions are actively running.
(Learn more about Azure Functions Hosting Options)
Step 3: Configure Basic Details
Once you select your plan, you need to fill out the core details for your application:
- Subscription: Choose your active subscription (e.g., Pay-As-You-Go).
- Resource Group: A Resource Group acts as a logical container for your Azure resources. You can select an existing one (like
AzureDemo) or create a new one. - Function App Name: Enter a globally unique name (e.g.,
funcappcloudnerchuko). This will form your default URL. - Runtime Stack: Azure Functions supports various languages like .NET, Node.js, and Java. For this guide, select PowerShell Core.
- Version: Leave as default (e.g.,
7.4). - Region: Select a region closest to you or your users (e.g.,
South India).
Step 4: Storage and Monitoring
Click Next to navigate through the subsequent configuration tabs:
Step 5: Review and Create
Skip through the Deployment and Tags tabs (leave them as default) and jump straight to Review + create.
Verify all the configurations you have set up. If everything looks good, hit Create.
Azure will now initialize the deployment. This usually takes just a minute or two. Once you see the “Your deployment is complete” screen, click on Go to resource.
Step 6: Create an HTTP Trigger Function
Now that your Function App is running, you need to actually create a function inside of it!
- On your Function App’s Overview page, scroll down and click on Create in Azure portal under the “Create functions in your preferred environment” section.
- You will be prompted to select a template. Azure offers many triggers (Timer, Azure Queue Storage, Blob Storage, etc.). Select HTTP trigger.
- Click Next and then Create.
(Learn more about Azure Functions HTTP Triggers)
Conclusion
Congratulations! You have successfully spun up a serverless environment and created your first HTTP-triggered PowerShell function in Microsoft Azure. From here, you can navigate to the Code + Test menu inside your function to write your custom PowerShell scripts and execute them directly via web requests!