|
1 |
| -# PSWorkerPrototype |
2 |
| -Prototype for Azure Functions PowerShell Language Worker |
| 1 | +# Azure Functions PowerShell Language Worker |
3 | 2 |
|
4 |
| -## Steps |
| 3 | +This repository will host the PowerShell language worker implementation for Azure Functions. |
| 4 | +We'll also be using it to track work items related to PowerShell support. |
| 5 | +Please feel free to leave comments about any of the features and design patterns. |
5 | 6 |
|
6 |
| -1. Modify `DefaultExecutablePath` in `worker.config.json` (to something like this `"C:\\Program Files\\dotnet\\dotnet.exe"`) |
7 |
| -2. `cd path/to/PSWorkerPrototype` |
8 |
| -3. `dotnet publish` |
9 |
| -4. Run: |
| 7 | +> 🚧 The project is currently **work in progress**. |
| 8 | +Please do not use in production as we expect developments over time. |
| 9 | +To receive important updates, including breaking changes announcements, |
| 10 | +watch the Azure App Service announcements repository. 🚧 |
10 | 11 |
|
11 |
| -```powershell |
12 |
| -# Windows if you installed the Azure Functions Core Tools via npm |
13 |
| -Remove-Item -Recurse -Force ~\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\powershell |
14 |
| -Copy-Item src\bin\Debug\netcoreapp2.1\publish ~\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\powershell -Recurse -Force |
| 12 | +## Overview |
15 | 13 |
|
16 |
| -# macOS if you installed the Azure Functions Core Tools via brew |
17 |
| -Remove-Item -Recurse -Force /usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.33/workers/powershell |
18 |
| -Copy-Item src/bin/Debug/netcoreapp2.1/publish /usr/local/Cellar/azure-functions-core-tools/2.0.1-beta.33/workers/powershell -Recurse -Force |
19 |
| -``` |
| 14 | +PowerShell support for Functions is based on [PowerShell Core 6.1](https://github.com/powershell/powershell), |
| 15 | +[Functions on Linux](https://blogs.msdn.microsoft.com/appserviceteam/2017/11/15/functions-on-linux-preview/), |
| 16 | +and the [Azure Functions runtime V2](https://docs.microsoft.com/en-us/azure/azure-functions/functions-versions). |
| 17 | + |
| 18 | +What's available? |
| 19 | + |
| 20 | +* Triggers / Bindings : HTTP/Webhook |
| 21 | + |
| 22 | +What's coming? |
| 23 | + |
| 24 | +* More triggers and bindings |
| 25 | +* Tooling integration |
| 26 | +* A bunch of other good things |
| 27 | + |
| 28 | +## Contributing |
| 29 | + |
| 30 | +> This project is **not currently taking pull requests** |
| 31 | +because it's still in the early development and is changing rapidly. |
| 32 | + |
| 33 | +This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). |
| 34 | +For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) |
| 35 | + |
| 36 | +with any additional questions or comments. |
| 37 | + |
| 38 | +## Building from source |
| 39 | + |
| 40 | +### Prereqs |
| 41 | + |
| 42 | +* [.NET 2.1 SDK](https://www.microsoft.com/net/download/visual-studio-sdks) |
| 43 | + |
| 44 | +### Build |
| 45 | + |
| 46 | +* Clone this repository |
| 47 | +* `cd azure-functions-powershell-worker` |
| 48 | +* `dotnet publish` |
| 49 | +* Make note of the location of the publish directory: |
| 50 | +`src/bin/Dubug/netcoreapp2.1/publish` |
| 51 | + |
| 52 | +### Run & Debug |
| 53 | + |
| 54 | +The PowerShell worker alone is not enough to establish the functions app, we also need the support from |
| 55 | +[Azure Functions Host](https://github.com/Azure/azure-functions-host). |
| 56 | +You may either use a published host CLI or use the in-development host. |
| 57 | +But both of the methods require you to attach to the .NET process if you want a step-by-step debugging experience. |
| 58 | + |
| 59 | +#### Published Host |
| 60 | + |
| 61 | +First, follow the [instructions to install the Azure Functions Core Tools](https://github.com/Azure/azure-functions-core-tools#installing). |
| 62 | +Then locate the `azure-functions-core-tools\bin\workers\` folder. |
| 63 | +Here are a few hints on where it could be located: |
| 64 | + |
| 65 | +On Windows if you installed via `npm` |
| 66 | +``` |
| 67 | +~\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\ |
| 68 | +``` |
| 69 | +On macOS if you installed via `brew` |
| 70 | +``` |
| 71 | +/usr/local/Cellar/azure-functions-core-tools/<version>/workers/ |
| 72 | +``` |
| 73 | + |
| 74 | +Copy the result of the `publish` directory into a `powershell` folder under `workers` so it looks something like: |
| 75 | +``` |
| 76 | +/usr/local/Cellar/azure-functions-core-tools/<version>/workers/powershell/<contents of publish directory> |
| 77 | +``` |
| 78 | + |
| 79 | +Then `cd` into a Function App with PowerShell as the worker runtime |
| 80 | +(NOTE: There's an example PowerShell Function App in the `examples` folder). |
| 81 | + |
| 82 | +Lastly, run: |
| 83 | + |
| 84 | +``` |
| 85 | +func start |
| 86 | +``` |
| 87 | + |
| 88 | +#### Latest Host |
| 89 | + |
| 90 | +A developer may also use the latest host code by cloning the git repository [Azure Functions Host](https://github.com/Azure/azure-functions-host). |
| 91 | +Now you need to navigate to the root folder of the host project and build it through: |
| 92 | + |
| 93 | +```sh |
| 94 | +dotnet restore WebJobs.Script.sln |
| 95 | +dotnet build WebJobs.Script.sln |
| 96 | +``` |
| 97 | + |
| 98 | +After the build succeeded, |
| 99 | +set the environment variable `"AzureWebJobsScriptRoot"` |
| 100 | +to the root folder path (the folder which contains the `host.json`) |
| 101 | +of your test functions app. |
| 102 | + |
| 103 | +Then copy the `publish` directory to |
| 104 | +`"<Azure Functions Host Root>/src/WebJobs.Script.WebHost/bin/Debug/netcoreapp2.1/workers/powershell"`. |
| 105 | + |
| 106 | +Then you can start the host but running: |
| 107 | +```sh |
| 108 | +dotnet ./src/WebJobs.Script.WebHost/bin/Debug/netcoreapp2.1/Microsoft.Azure.WebJobs.Script.WebHost.dll |
| 109 | +``` |
| 110 | + |
| 111 | +> Note: Remember to remove `"AzureWebJobsScriptRoot"` |
| 112 | +environment variable after you have finished debugging, |
| 113 | +because it will also influence the `func` CLI tool. |
0 commit comments