Skip to content

Instantly share code, notes, and snippets.

@JustinGrote
Last active April 5, 2020 14:49
Show Gist options
  • Save JustinGrote/d751dd1b05ef0db35921da01e375a5ab to your computer and use it in GitHub Desktop.
Save JustinGrote/d751dd1b05ef0db35921da01e375a5ab to your computer and use it in GitHub Desktop.
Powershell Azure Function Template Starter
function New-AzFunction {
[CmdletBinding(SupportsShouldProcess)]
param(
[Parameter(Mandatory)][String]$Name,
[ValidateSet(
"Azure Blob Storage trigger",
"Azure Cosmos DB trigger",
"Azure Event Grid trigger",
"Azure Event Hub trigger",
"HTTP trigger",
"IoT Hub (Event Hub)",
"Azure Queue Storage trigger",
"SendGrid",
"Azure Service Bus Queue trigger",
"Azure Service Bus Topic trigger",
"SignalR negotiate HTTP trigger",
"Timer trigger"
)][String]$Template = 'HTTP Trigger',
[String]$Language = 'Powershell'
)
if ($PSCmdlet.ShouldProcess($pwd,"Creating $Language $Template function $Name")) {
$funcExe = (Get-Command func -Type 'Application' -ErrorAction stop).Source
& $funcExe new --language $Language --template $Template --name $Name
}
}
@JustinGrote
Copy link
Author

The first error is a psreadline error, please install powershell preview extension for vscode.

The second error is because I assumed there would be only one "func" installed on your system

This command is for creating local functions for development. For deployment you may want to check out the Azure Functions Vscode extension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment