Skip to content

Commit d3556aa

Browse files
authored
Add instructions for running Durable functions on Azure (#475)
1 parent d397989 commit d3556aa

File tree

1 file changed

+62
-55
lines changed

1 file changed

+62
-55
lines changed
Lines changed: 62 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,54 @@
1-
# How to try experimental Durable PowerShell functions
1+
# How to try Durable PowerShell functions
22

3-
## **PLEASE READ THIS:**
3+
## Please note
44

5-
> This is an experimental feature. Do **not** enable or try to use it for production purposes. The programming model may change, so the sample code or any app code you come up with may not work in the next versions. The main purpose of making it available now is to enable experimentation and early feedback. **Your feedback is highly appreciated**, and please feel free to file [GitHub issues](https://github.com/Azure/azure-functions-powershell-worker/issues/new).
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)
613

7-
> If you want to try the latest version locally, consider following these instructions as they automate and simplify the steps below: https://git.io/PS7DurableFunctionsNow
14+
## Local setup
815

9-
> You can also get started using a dev container with Visual Studio Code Remote for Containers or Visual Studio Online: https://github.com/anthonychu/powershell-durable-preview
16+
_This step is required if you intend to run Durable PowerShell functions on your local machine. Otherwise, feel free to skip this step._
1017

11-
## 1. PowerShell worker version
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:
1219

13-
At the moment of writing this (March 14, 2020), the Durable PowerShell implementation deployed to Azure is outdated. If you want to follow the instructions below, please install a more recent version locally:
14-
- 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).
15-
- Download the latest PowerShell worker package:
16-
``` PowerShell
17-
Save-Package -Name 'Microsoft.Azure.Functions.PowershellWorker.PS7' -Source 'https://ci.appveyor.com/nuget/azure-functions-powershell-wor-0842fakagqy6/' -ProviderName NuGet -Path ~\Downloads\
18-
```
19-
- 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.
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
2021

21-
If you want to try this on Azure, you will have to wait a bit longer.
22+
- **Option 2**: Consider following these instructions as they automate and simplify the steps below: https://git.io/PS7DurableFunctionsNow
2223

23-
## 2. Sample app
24+
- **Option 3**: Install the latest PowerShell Worker build manually:
2425

25-
Start with the sample durable app at `examples/durable/DurableApp`.
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).
2627

27-
Note:
28+
- Download the latest PowerShell worker package:
2829

29-
- Please make sure you are using Azure Functions **v3** runtime. There are no plans to support Durable PowerShell on Azure Functions **v1** or **v2**.
30-
- Only Durable Functions **2.x** will be 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, and there is no plan to support Durable Functions **1.x** officially in any case.
31-
- Please make sure you are using the sample code version corresponding to the version of the PowerShell Worker. The programming model is still changing, so older or newer samples may not work. So, if you are trying Durable PowerShell on Azure, use the samples tagged with the version of the PowerShell worker deployed to Azure. Alternatively, take the latest PowerShell Worker code from the **dev** branch, and rebuild and run the PowerShell Worker locally.
32-
- Only a limited number of patterns is enabled at this point:
33-
- [Function chaining](https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#chaining)
34-
- [Fan out/fan in](https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#fan-in-out)
35-
- [Async HTTP APIs](https://docs.microsoft.com/azure/azure-functions/durable/durable-functions-overview?tabs=csharp#async-http)
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._
3641
37-
## 3. Install the required extensions
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.
3844
39-
Before deploying your app, run the following command in the app directory:
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 command in the app directory:
4052
4153
``` bash
4254
func extensions install --powershell
@@ -48,59 +60,50 @@ Please note that the Microsoft.Azure.WebJobs.Extensions.DurableTask package shou
4860
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.0.0" />
4961
```
5062

51-
## 4. App settings
63+
### 2. Configure app settings
5264

5365
Set the following app settings (if running on Azure) or just use the sample local.settings.json (if running locally):
54-
55-
``` json
56-
{
57-
"Values": {
58-
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
59-
"AzureWebJobsFeatureFlags": "AllowSynchronousIO",
60-
"FUNCTIONS_WORKER_RUNTIME": "powershell",
61-
"PSWorkerInProcConcurrencyUpperBound": 10
62-
}
63-
}
64-
```
65-
66-
- 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.
66+
- 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.
6767
- `AzureWebJobsFeatureFlags` must contain `AllowSynchronousIO`. Don't ask.
68-
- `FUNCTIONS_WORKER_RUNTIME` must be set to `powershell`.
6968
- 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.
7069

71-
## 5. Starting the app
70+
### 3. Deploy the app
7271

73-
If you have `UseDevelopmentStorage=true` as the `AzureWebJobsStorage` value, remember to start the Azure Storage Emulator.
72+
If running locally, skip the step, otherwise deploy the app to Azure as you normally would.
7473

75-
Configure the environment variable FUNCTIONS_WORKER_RUNTIME_VERSION to select PowerShell 7:
74+
### 4. Start the app
7675

77-
``` PowerShell
78-
$env:FUNCTIONS_WORKER_RUNTIME_VERSION = '~7'
79-
```
76+
If running locally:
77+
- If you have `UseDevelopmentStorage=true` as the `AzureWebJobsStorage` value, remember to start the Azure Storage Emulator first.
78+
- Configure the environment variable FUNCTIONS_WORKER_RUNTIME_VERSION to select PowerShell 7:
79+
``` PowerShell
80+
$env:FUNCTIONS_WORKER_RUNTIME_VERSION = '~7'
81+
```
82+
- Start the app:
83+
``` bash
84+
func start
85+
```
8086

81-
and start the app:
87+
If running on Azure:
88+
- Just start the app as you normally would.
8289

83-
``` bash
84-
func start
85-
```
86-
87-
## 6. Function Chaining pattern
90+
### 5. Try Function Chaining pattern
8891

8992
Start the FunctionChainingStart function:
9093

9194
``` PowerShell
9295
Invoke-RestMethod 'http://localhost:7071/api/FunctionChainingStart'
9396
```
9497

95-
## 7. Fan-out/Fan-in pattern
98+
### 6. Try Fan-out/Fan-in pattern
9699

97100
Start the FanOutFanInStart function:
98101

99102
``` PowerShell
100103
Invoke-RestMethod 'http://localhost:7071/api/FanOutFanInStart'
101104
```
102105

103-
## 8. Async HTTP APIs
106+
### 7. Try Async HTTP APIs pattern
104107

105108
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:
106109

@@ -115,3 +118,7 @@ while ($true) {
115118
}
116119
}
117120
```
121+
122+
### 8. Have fun, experiment, participate!
123+
124+
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).

0 commit comments

Comments
 (0)