Skip to content

Update readme with limitations, quickstart link #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 28 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# Durable Functions for Python

The `azure-functions-durable` [pip](https://pypi.org/project/azure-functions-durable/) package allows you to write [Durable Functions](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview) for Python(https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python). Durable Functions is an extension of [Azure Functions](https://docs.microsoft.com/en-us/azure/azure-functions/functions-overview) that lets you write stateful functions and workflows in a serverless environment. The extension manages state, checkpoints, and restarts for you. Durable Functions' advantages include:
The `azure-functions-durable` [pip](https://pypi.org/project/azure-functions-durable/) package allows you to write [Durable Functions](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-overview) for [Python](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-python). Durable Functions is an extension of [Azure Functions](https://docs.microsoft.com/en-us/azure/azure-functions/functions-overview) that lets you write stateful functions and workflows in a serverless environment. The extension manages state, checkpoints, and restarts for you. Durable Functions' advantages include:

* Define workflows in code. No JSON schemas or designers are needed.
* Call other functions synchronously and asynchronously. Output from called functions can be saved to local variables.
Expand All @@ -25,81 +25,53 @@ A durable function, or _orchestration_, is a solution made up of different types

Durable Functions' function types and features are documented in-depth [here.](https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-types-features-overview)

## Getting Started

You can follow the instructions below to get started with a function chaining example, or follow the general checklist below:

1. Install prerequisites:
- [Azure Functions Core Tools version 2.x](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local#install-the-azure-functions-core-tools)
- [Azure Storage Emulator](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-emulator) (Windows) or an actual Azure storage account (Mac or Linux)
- Python 3.6 or later
## Current limitations

2. [Create an Azure Functions app.](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-function-python)
We're actively working on Python support for Durable Functions and we expect a Public Preview announcement in Q2 CY2020. The following are the current known limitations.

3. Install the Durable Functions extension

Run this command from the root folder of your Azure Functions app:
```bash
func extensions install -p Microsoft.Azure.WebJobs.Extensions.DurableTask -v 1.8.3
```
### Functionality

**durable-functions requires Microsoft.Azure.WebJobs.Extensions.DurableTask 1.7.0 or greater.**
* `DurableOrchestrationContext.create_timer()` is not yet supported (coming soon [#35](https://github.com/Azure/azure-functions-durable-python/issues/35))
* Sub-orchestrations are not yet supported (planned [#62](https://github.com/Azure/azure-functions-durable-python/issues/62))
* Durable Entities are not yet supported (not yet planned [#96](https://github.com/Azure/azure-functions-durable-python/issues/96))

4. Install the `azure-durable-functions` pip package at the root of your function app:
### Tooling

Create and activate virtual environment
```
python3 -m venv env
source env/bin/activate
```
* Python Durable Functions requires updated versions of Azure Functions Core Tools that includes Python worker [1.1.0](https://github.com/Azure/azure-functions-python-worker/releases/tag/1.1.0), templates ([bundle-1.2.0](https://github.com/Azure/azure-functions-templates/releases/tag/bundle-1.2.0)), and extension bundles ([1.2.0](https://github.com/Azure/azure-functions-extension-bundles/releases/tag/1.2.0)) that are not yet released (ETA May 2020). Use the VS Code dev container in the [Getting Started](#getting-started) section to access a development environment with the required versions of the tools installed.

```bash
pip install azure-durable-functions
```
### Deployment

5. Write an activity function ([see sample](./samples/python_durable_bindings/DurableActivity)):
```python
def main(name: str) -> str:
logging.info(f"Activity Triggered: {name}")
# your code here
```
* Python Durable Functions requires an updated version of the Azure Functions Python language worker ([1.1.0](https://github.com/Azure/azure-functions-python-worker/releases/tag/1.1.0)) that is not yet available in Azure. Deploy your Python Durable Functions apps in containers (requires Premium or App Service plans). (Linux consumption plan support ETA May 2020)

6. Write an orchestrator function ([see sample](./samples/python_durable_bindings/DurableOrchestrationTrigger)):
## Getting Started

```python
def main(context: str):
orchestrate = df.Orchestrator.create(generator_function)
result = orchestrate(context)
return result
```
Follow these instructions to get started with Durable Functions in Python:

**Note:** Orchestrator functions must follow certain [code constraints.](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-checkpointing-and-replay#orchestrator-code-constraints)
**🚀 [Python Durable Functions quickstart](https://aka.ms/pythondurable)**

7. Write your client function ([see sample](./samples/DurableOrchestrationClient/)):
## Samples

TBD
Take a look at this project's [samples directory](./samples/):

**Note:** Client functions are started by a trigger binding available in the Azure Functions 2.x major version. [Read more about trigger bindings and 2.x-supported bindings.](https://docs.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#overview)
* [Function Chaining](./samples/function_chaining)
* [Fan-out/Fan-in - Simple](./samples/fan_out_fan_in)
* [Fan-out/Fan-in - TensorFlow](./samples/fan_out_fan_in_tensorflow)
* [External Events - Human Interaction & Timeouts](./samples/external_events)

## Samples
### Orchestrator example

The [Durable Functions samples](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-install) demonstrate several common use cases. They are located in the [samples directory.](./samples/) Descriptive documentation is also available:
```python
import azure.durable_functions as df

* [Function Chaining - Hello Sequence](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-sequence)
* [Fan-out/Fan-in - Cloud Backup](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-cloud-backup)
* [Monitors - Weather Watcher](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-monitor)
* [Human Interaction & Timeouts - Phone Verification](https://docs.microsoft.com/en-us/azure/azure-functions/durable-functions-phone-verification)

```python
def generator_function(context):
outputs = []
def orchestrator_function(context: df.DurableOrchestrationContext):
task1 = yield context.call_activity("DurableActivity", "One")
task2 = yield context.call_activity("DurableActivity", "Two")
task3 = yield context.call_activity("DurableActivity", "Three")

outputs.append(task1)
outputs.append(task2)
outputs.append(task3)

outputs = [task1, task2, task3]
return outputs


main = df.Orchestrator.create(orchestrator_function)
```