|
1 | | -# How to try Durable PowerShell functions |
2 | | - |
3 | | -## Please note |
4 | | - |
5 | | -- This feature is getting ready for Public Preview. If you use it for production purposes, be aware that the programming model may change before GA, so the sample code or any app code you come up with may not work in the next versions. |
6 | | -- **Your feedback is highly appreciated**, please feel free to file [GitHub issues](https://github.com/Azure/azure-functions-powershell-worker/issues/new) if anything does not work as expected. |
7 | | -- Make sure you are using Azure Functions **v3** runtime. There are no plans to support Durable PowerShell on Azure Functions **v1** or **v2**. |
8 | | -- Only Durable Functions **2.x** will be officially supported (see [Durable Functions versions overview](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-versions)). Technically, the current implementation works with Durable Functions **1.x** as well. However, it may stop working before GA. |
9 | | -- Only a limited number of patterns is enabled at this point: |
10 | | - - [Function chaining](https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#chaining) |
11 | | - - [Fan out/fan in](https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#fan-in-out) |
12 | | - - [Async HTTP APIs](https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#async-http) |
13 | | - |
14 | | -## Local setup |
15 | | - |
16 | | -_This step is required if you intend to run Durable PowerShell functions on your local machine. Otherwise, feel free to skip this step._ |
17 | | - |
18 | | -At the moment of writing this (June 11, 2020), the PowerShell Worker version deployed by Azure Functions Core Tools does support Durable Functions yet. If you want to run Durable PowerShell functions locally, consider the following options: |
19 | | - |
20 | | -- **Option 1**: Get started using a dev container with Visual Studio Code Remote for Containers or Visual Studio Online: https://github.com/anthonychu/powershell-durable-preview |
21 | | - |
22 | | -- **Option 2**: Consider following these instructions as they automate and simplify the steps below: https://git.io/PS7DurableFunctionsNow |
23 | | - |
24 | | -- **Option 3**: Install the latest PowerShell Worker build manually: |
25 | | - |
26 | | - - Install [Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local?tabs=windows%2Ccsharp%2Cbash#install-the-azure-functions-core-tools) **v3.x** (if not installed yet). |
27 | | - |
28 | | - - Download the latest PowerShell worker package: |
29 | | - |
30 | | - ``` PowerShell |
31 | | - Save-Package -Name 'Microsoft.Azure.Functions.PowershellWorker.PS7' -Source 'https://ci.appveyor.com/nuget/azure-functions-powershell-wor-0842fakagqy6/' -ProviderName NuGet -Path ~\Downloads\ |
32 | | - ``` |
33 | | -
|
34 | | - - Rename the downloaded .nuget file to .zip and extract the content of the `contentFiles\any\any\workers\powershell` folder to `workers\powershell` under the [Core Tools](https://github.com/Azure/azure-functions-powershell-worker/blob/dev/README.md#published-host), overwriting the existing files. |
35 | | -
|
36 | | -- **Option 4**: Wait for the next (higher than 3.0.2534) release of Azure Functions Core Tools. |
37 | | -
|
38 | | -## Azure setup |
39 | | -
|
40 | | -_This step is required if you intend to run Durable PowerShell functions on Azure. Otherwise, feel free to skip this step._ |
41 | | -
|
42 | | -- Create a PowerShell Function app on Azure. |
43 | | -- Use the [instructions](https://github.com/Azure/azure-functions-powershell-worker/issues/371#issuecomment-641026259) to switch your app to PowerShell 7. |
44 | | -
|
45 | | -## Sample app |
46 | | -
|
47 | | -Start with the sample app at `examples/durable/DurableApp` in this repository. |
48 | | -
|
49 | | -### 1. Install extensions |
50 | | -
|
51 | | -Before deploying or starting it, run the following commands in the app directory: |
52 | | -
|
53 | | -``` bash |
54 | | -dotnet add package Microsoft.Azure.WebJobs.Extensions.DurableTask |
55 | | -func extensions install --powershell |
56 | | -``` |
57 | | - |
58 | | -### 2. Configure app settings |
59 | | - |
60 | | -Set the following app settings (if running on Azure) or just use the sample local.settings.json (if running locally): |
61 | | -- Make sure `AzureWebJobsStorage` [points to a valid Azure storage account](https://docs.microsoft.com/azure/azure-functions/functions-app-settings#azurewebjobsstorage). This storage is required for data persisted by Durable Functions. When you create a new Function app on Azure, it normally points to an automatically provisioned storage account. If you intend to run the app locally, you can either keep the "UseDevelopmentStorage=true" value in the sample local.settings.json (in this case you will also need to install and start Azure Storage Emulator), or replace it with a connection string pointing to a real Azure storage account. |
62 | | -- You may need to adjust `PSWorkerInProcConcurrencyUpperBound` to increase [concurrency](https://docs.microsoft.com/azure/azure-functions/functions-reference-powershell#concurrency) for the Fan-out/Fan-in pattern. |
63 | | - |
64 | | -### 3. Deploy the app |
65 | | - |
66 | | -If running locally, skip the step, otherwise deploy the app to Azure as you normally would. |
67 | | - |
68 | | -### 4. Start the app |
69 | | - |
70 | | -If running locally: |
71 | | -- If you have `UseDevelopmentStorage=true` as the `AzureWebJobsStorage` value, remember to start the Azure Storage Emulator first. |
72 | | -- Configure the environment variable FUNCTIONS_WORKER_RUNTIME_VERSION to select PowerShell 7: |
73 | | - ``` PowerShell |
74 | | - $env:FUNCTIONS_WORKER_RUNTIME_VERSION = '~7' |
75 | | - ``` |
76 | | -- Start the app: |
77 | | - ``` bash |
78 | | - func start |
79 | | - ``` |
80 | | - |
81 | | -If running on Azure: |
82 | | -- Just start the app as you normally would. |
83 | | - |
84 | | -### 5. Try Function Chaining pattern |
85 | | - |
86 | | -Start the FunctionChainingStart function: |
87 | | - |
88 | | -``` PowerShell |
89 | | -Invoke-RestMethod 'http://localhost:7071/api/FunctionChainingStart' |
90 | | -``` |
91 | | - |
92 | | -### 6. Try Fan-out/Fan-in pattern |
93 | | - |
94 | | -Start the FanOutFanInStart function: |
95 | | - |
96 | | -``` PowerShell |
97 | | -Invoke-RestMethod 'http://localhost:7071/api/FanOutFanInStart' |
98 | | -``` |
99 | | - |
100 | | -### 7. Try Async HTTP APIs pattern |
101 | | - |
102 | | -When you invoke FunctionChainingStart or FanOutFanInStart, it returns an HTTP 202 response with the orchestration management URLs, so you can start invoking statusQueryGetUri and wait for the orchestration to complete: |
103 | | - |
104 | | -``` PowerShell |
105 | | -$invokeResponse = Invoke-RestMethod 'http://localhost:7071/api/FunctionChainingStart' |
106 | | -while ($true) { |
107 | | - $status = Invoke-RestMethod $invokeResponse.statusQueryGetUri |
108 | | - $status |
109 | | - Start-Sleep -Seconds 2 |
110 | | - if ($status.runtimeStatus -eq 'Completed') { |
111 | | - break; |
112 | | - } |
113 | | -} |
114 | | -``` |
115 | | - |
116 | | -### 8. Have fun, experiment, participate! |
117 | | - |
118 | | -Please let us know how you use Durable PowerShell functions and what does not (_yet_) work as you expect. **Your feedback is highly appreciated**, please feel free to file [GitHub issues](https://github.com/Azure/azure-functions-powershell-worker/issues/new). |
| 1 | +No need for the experimental instructions anymore, as PowerShell support in Durable Functions is now [generally available](https://azure.microsoft.com/en-us/updates/powershell-support-in-durable-functions-is-now-generally-available). |
0 commit comments