Skip to content

01 - Run Locally (Consumption)

Scaffold and run a PowerShell Azure Functions app locally before deploying to the Consumption (Y1) plan.

Prerequisites

Tool Version Purpose
PowerShell 7.4+ Local runtime matching the worker
Azure Functions Core Tools v4 Start the local host and publish
Azure CLI 2.61+ Provision and configure Azure resources
Azurite (optional) latest Local Storage emulator for triggers

Consumption (Y1) basics

Consumption (Y1) is serverless with scale-to-zero and per-execution billing. PowerShell runs on version 7.4 on this plan.

What You'll Build

You will scaffold a PowerShell function app with an anonymous HTTP trigger, run it on the local Functions host, and verify the endpoint responds.

Steps

Step 1 - Scaffold the project

func init MyPsApp --powershell
cd MyPsApp
func new --name HttpExample --template "HTTP trigger" --authlevel anonymous

Step 2 - Configure local settings

local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "powershell",
    "FUNCTIONS_WORKER_RUNTIME_VERSION": "7.4"
  }
}

Step 3 - Review the function

HttpExample/run.ps1:

param($Request, $TriggerMetadata)

$name = $Request.Query.Name
if (-not $name) { $name = $Request.Body.Name }

$body = if ($name) { "Hello, $name." } else { "Pass a name in the query string or body." }

Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
    StatusCode = [System.Net.HttpStatusCode]::OK
    Body       = $body
})

Step 4 - Start the host

func host start

Step 5 - Call the endpoint

curl "http://localhost:7071/api/HttpExample?name=Azure"

Verification

Functions:
    HttpExample: [GET,POST] http://localhost:7071/api/HttpExample

The curl call returns Hello, Azure.

Next Steps

You now have local parity and can deploy to Consumption (Y1).

Next: 02 - First Deploy

See Also

Sources

Legacy hosting path

Consumption plan (Y1) content is provided for existing workloads. For most new serverless applications, prefer Flex Consumption.