PowerShell language worker for Azure Functions.
Перейти к файлу
David Justo fa76236278
make official pipeline run nightly (#1096)
2024-10-23 10:39:12 -07:00
.devcontainer Add .devcontainer (#618) 2021-04-19 18:59:51 -07:00
.github Add codeQL action and nightly runs to the public CI (#1083) 2024-10-04 16:26:32 -06:00
.vscode Support `profile.ps1` and remove auto-auth to azure (#114) 2018-12-12 21:17:58 -08:00
docs Update durable-experimental-instructions.md 2021-05-26 15:10:30 -07:00
eng/ci make official pipeline run nightly (#1096) 2024-10-23 10:39:12 -07:00
examples Add Get-DurableStatus and Stop-DurableOrchestration commands (#629) 2021-04-26 15:52:49 -07:00
images Replace `iconUrl` with `icon` (#336) 2019-09-24 10:35:01 -07:00
package Upgrade PowerShell 7.4 to SDK 7.4.0-preview.2 with .Net 8 Preview.3 (#940) 2023-04-19 19:41:21 -07:00
protobuf OpenTelemetry support in worker (#1049) 2024-04-12 13:00:00 -06:00
src Bump System.Text.Json from 8.0.4 to 8.0.5 2024-10-09 11:03:19 -06:00
test Bump System.Text.Json from 8.0.4 to 8.0.5 2024-10-09 11:03:19 -06:00
tools Update PowerShell SDK to 7.4.5 (#1092) 2024-10-03 11:16:21 -06:00
.gitattributes Log function load and invocation performance data (#335) 2019-09-24 14:16:47 -07:00
.gitignore [Durable] Implement retry policy support (#590) 2021-02-23 14:05:52 -08:00
Check-CsprojVulnerabilities.ps1 Updating build to check for vulnerabilities (#1026) 2023-12-08 22:50:26 -08:00
LICENSE Initial commit 2018-07-27 09:17:18 -07:00
PowerShellWorker.Common.props Enable building PowerShell 7.2 (#660) 2021-08-06 13:59:56 -07:00
README.md Update README.md (#1077) 2024-06-25 14:17:45 -06:00
SECURITY.md Create SECURITY.md 2021-10-06 09:01:52 -07:00
ThirdPartyNotices.txt add ThirdPartyNotices (#32) 2018-09-06 18:37:58 -07:00
azure-functions-powershell-worker.sln Enable installing function app dependencies via requirements.psd1. (#166) 2019-03-18 16:23:04 -07:00
azure-pipelines-e2e-integration-tests.yml Update pipeline to pull down secrets from key vault (#1012) 2023-10-16 16:03:34 -07:00
build.ps1 Convert build pipeline to 1ES (#1061) 2024-06-20 11:35:30 -06:00
create_new_worker_instructions.md Shut off MD module upgrades after 7.4 EOL (#1084) 2024-09-25 15:27:02 -06:00
release_notes.md Rename DF components (#793) 2022-07-12 12:58:49 -07:00
upgrade_ps_sdk_instructions.md Add PowerShell SDK upgrade instructions (#987) 2023-08-24 10:14:06 -07:00

README.md

azure-functions-logo

Branch Status
dev Build Status

Azure Functions PowerShell Language Worker

This repository will host the PowerShell language worker implementation for Azure Functions. We'll also be using it to track work items related to PowerShell support. Please feel free to leave comments about any of the features and design patterns.

Overview

PowerShell support for Functions is based on PowerShell Core 7, Functions on Linux, and the Azure Functions runtime V4.

What's available?

Triggers / Bindings

  • HTTP Trigger (Webhook)
  • Timer Trigger
  • Blob Trigger
  • Queue Trigger

What's coming?

  • More triggers and bindings
  • Tooling integration
  • A bunch of other good things

Contributing

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Building from source

Prereqs

Build

  1. Clone this repository
  2. cd azure-functions-powershell-worker
  3. ./build.ps1

NOTE: If you're missing a dependency, you will be asked to run ./build.ps1 -Bootstrap

Run & Debug

The PowerShell worker alone is not enough to establish the functions app, we also need the support from Azure Functions Host. You may either use a published host CLI or use the in-development host. But both of the methods require you to attach to the .NET process if you want a step-by-step debugging experience.

Published Host

First, follow the instructions to install the Azure Functions Core Tools. Then locate the azure-functions-core-tools\bin\workers\ folder. Here are a few hints on where it could be located:

On Windows if you installed via npm

~\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\

On macOS if you installed via brew

/usr/local/Cellar/azure-functions-core-tools/<version>/workers/

Under the workers/powershell folder, create a folder with the name 7.4 if it does not exist yet. Copy the result of the publish directory into the workers/powershell/7.4 folder, and copy the publish/worker.config.json file into the workers/powershell folder:

Copy-Item -Recurse -Force ./src/bin/Debug/net8.0/publish/ "/usr/local/Cellar/azure-functions-core-tools/$(func --version)/workers/powershell/7.4"
Copy-Item -Recurse -Force ./src/bin/Debug/net8.0/publish/worker.config.json "/usr/local/Cellar/azure-functions-core-tools/$(func --version)/workers/powershell"

NOTE: if the powershell folder already exists, you should delete it or debugging won't work.

Then cd into a Function App with PowerShell as the worker runtime (NOTE: There's an example PowerShell Function App in the examples folder).

Set the environment variable FUNCTIONS_WORKER_RUNTIME_VERSION to 7.4, or add this as an app setting to the local.settings.json file.

Lastly, run:

func start

NOTE: If you would like to see more out of the logs, see the logging section in the Azure Functions Host repo.

Latest Host

A developer may also use the latest host code by cloning the git repository Azure Functions Host. Now you need to navigate to the root folder of the host project and build it through:

dotnet restore WebJobs.Script.sln
dotnet build WebJobs.Script.sln

After the build succeeded, set the environment variable "AzureWebJobsScriptRoot" to the root folder path (the folder which contains the host.json) of your test functions app.

Under the workers/powershell folder, create a folder with the name 7.4 if it does not exist yet. Then copy the publish directory to workers/powershell/7.4, and the publish/worker.config.json to workers/powershell:

Copy-Item -Recurse -Force ./src/bin/Debug/net8.0/publish/ "<Azure Functions Host Root>/src/WebJobs.Script.WebHost/bin/Debug/net8.0/workers/powershell/7.4"
Copy-Item -Force ./src/bin/Debug/net8.0/publish/worker.config.json "<Azure Functions Host Root>/src/WebJobs.Script.WebHost/bin/Debug/net8.0/workers/powershell"

Then you can start the host by running:

dotnet ./src/WebJobs.Script.WebHost/bin/Debug/net8.0/Microsoft.Azure.WebJobs.Script.WebHost.dll

Note: Remember to remove "AzureWebJobsScriptRoot" environment variable after you have finished debugging, because it will also influence the func CLI tool.

Packaging

To package the PowerShell Language Worker as a nupkg, do the following:

  • cd azure-functions-powershell-worker
  • dotnet publish
  • cd package
  • dotnet pack

That will place a Microsoft.Azure.Functions.PowerShellWorker.*.nupkg in:

azure-functions-powershell-worker/package/bin/Debug

It pulls the contents of the publish folder in:

azure-functions-powershell-worker/src/bin/Debug/net8.0/publish

if you specify a different Configuration or TargetFramework that will be honored.