Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
GitHub Copilot for Azure plugin providing Azure service management and development assistance inside Claude Code and IDEs.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/services/functions/runtimes/powershell.md
1# PowerShell — Azure Functions Triggers & Bindings23> **Model**: PowerShell uses `function.json` for binding definitions + `run.ps1` for handler code.4> Each function lives in its own directory: `<FunctionName>/function.json` + `run.ps1`56## Project Structure78```9src/10├── host.json11├── local.settings.json12├── requirements.psd113├── profile.ps114├── HttpFunction/15│ ├── function.json16│ └── run.ps117└── TimerFunction/18├── function.json19└── run.ps120```2122## HTTP Trigger2324**function.json:**25```json26{27"bindings": [28{ "authLevel": "anonymous", "type": "httpTrigger", "direction": "in",29"name": "Request", "methods": ["get", "post"] },30{ "type": "http", "direction": "out", "name": "Response" }31]32}33```3435**run.ps1:**36```powershell37param($Request, $TriggerMetadata)38$name = $Request.Query.Name39Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{40StatusCode = [HttpStatusCode]::OK41Body = "Hello, $name!"42})43```4445## Blob Storage4647**function.json:**48```json49{50"bindings": [51{ "name": "InputBlob", "type": "blobTrigger", "direction": "in",52"path": "samples-workitems/{name}", "connection": "AzureWebJobsStorage" },53{ "name": "OutputBlob", "type": "blob", "direction": "out",54"path": "output/{name}", "connection": "AzureWebJobsStorage" }55]56}57```5859**run.ps1:**60```powershell61param($InputBlob, $TriggerMetadata)62Write-Host "Blob: $($TriggerMetadata.Name), Size: $($InputBlob.Length)"63Push-OutputBinding -Name OutputBlob -Value $InputBlob64```6566## Queue Storage6768**function.json:**69```json70{71"bindings": [72{ "name": "QueueItem", "type": "queueTrigger", "direction": "in",73"queueName": "myqueue-items", "connection": "AzureWebJobsStorage" },74{ "name": "OutputQueue", "type": "queue", "direction": "out",75"queueName": "outqueue", "connection": "AzureWebJobsStorage" }76]77}78```7980**run.ps1:**81```powershell82param($QueueItem, $TriggerMetadata)83Write-Host "Queue message: $QueueItem"84Push-OutputBinding -Name OutputQueue -Value "Processed: $QueueItem"85```8687## Timer8889**function.json:**90```json91{92"bindings": [93{ "name": "Timer", "type": "timerTrigger", "direction": "in",94"schedule": "0 */5 * * * *" }95]96}97```9899**run.ps1:**100```powershell101param($Timer)102Write-Host "Timer triggered at: $(Get-Date)"103```104105## Event Grid106107**function.json:**108```json109{110"bindings": [111{ "name": "EventGridEvent", "type": "eventGridTrigger", "direction": "in" }112]113}114```115116**run.ps1:**117```powershell118param($EventGridEvent, $TriggerMetadata)119Write-Host "Event: $($EventGridEvent.subject) - $($EventGridEvent.eventType)"120```121122## Cosmos DB123124**function.json:**125```json126{127"bindings": [128{ "name": "Documents", "type": "cosmosDBTrigger", "direction": "in",129"connectionStringSetting": "CosmosDBConnection", "databaseName": "mydb",130"containerName": "mycontainer", "createLeaseContainerIfNotExists": true },131{ "name": "OutputDoc", "type": "cosmosDB", "direction": "out",132"connectionStringSetting": "CosmosDBConnection", "databaseName": "mydb",133"containerName": "outcontainer" }134]135}136```137138**run.ps1:**139```powershell140param($Documents, $TriggerMetadata)141foreach ($doc in $Documents) {142Write-Host "Changed doc: $($doc.id)"143}144```145146## Service Bus147148**function.json:**149```json150{151"bindings": [152{ "name": "Message", "type": "serviceBusTrigger", "direction": "in",153"queueName": "myqueue", "connection": "ServiceBusConnection" },154{ "name": "OutputMessage", "type": "serviceBus", "direction": "out",155"queueName": "outqueue", "connection": "ServiceBusConnection" }156]157}158```159160**run.ps1:**161```powershell162param($Message, $TriggerMetadata)163Write-Host "Message: $Message"164Push-OutputBinding -Name OutputMessage -Value "Processed: $Message"165```166167## Event Hubs168169**function.json:**170```json171{172"bindings": [173{ "name": "Events", "type": "eventHubTrigger", "direction": "in",174"eventHubName": "myeventhub", "connection": "EventHubConnection",175"cardinality": "many" }176]177}178```179180## Table Storage181182**function.json:**183```json184{185"bindings": [186{ "name": "TableEntity", "type": "table", "direction": "in",187"tableName": "mytable", "partitionKey": "{pk}", "rowKey": "{rk}",188"connection": "AzureWebJobsStorage" },189{ "name": "TableOut", "type": "table", "direction": "out",190"tableName": "mytable", "connection": "AzureWebJobsStorage" }191]192}193```194195## SQL196197**function.json:**198```json199{200"bindings": [201{ "name": "Changes", "type": "sqlTrigger", "direction": "in",202"tableName": "dbo.MyTable", "connectionStringSetting": "SqlConnection" }203]204}205```206207## SendGrid208209**function.json:**210```json211{212"bindings": [213{ "name": "Mail", "type": "sendGrid", "direction": "out",214"apiKey": "SendGridApiKey", "from": "[email protected]" }215]216}217```218219> **Note**: PowerShell always requires `function.json` — it does not support inline binding definitions.220221> Full reference: [Azure Functions PowerShell developer guide](https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell)222