Giter VIP home page Giter VIP logo

Comments (9)

AndreRicardo-Zoetis avatar AndreRicardo-Zoetis commented on July 24, 2024 1

I'm wondering the same as I would like to have client = df.DurableOrchestrationClient(starter) as Global Dependency in FastAPI. So that we can use durable functions Orchestrator but called from regular FastAPI endpoints.

Here is an example with a custom orchestration status, but again needs the starter: str
https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-custom-orchestration-status?tabs=python#e1_sayhello-activity-function

For the sake of it starter in v1 is:

{
    "taskHubName": "TestHubName",
    "connectionName": null,
    "creationUrls": {
        "createNewInstancePostUri": "http://localhost:7071/runtime/webhooks/durabletask/orchestrators/{functionName}[/{instanceId}]?code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
        "createAndWaitOnNewInstancePostUri": "http://localhost:7071/runtime/webhooks/durabletask/orchestrators/{functionName}[/{instanceId}]?timeout={timeoutInSeconds}&pollingInterval={intervalInSeconds}&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ=="
    },
    "managementUrls": {
        "id": "INSTANCEID",
        "statusQueryGetUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/INSTANCEID?taskHub=TestHubName&connection=Storage&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
        "sendEventPostUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/INSTANCEID/raiseEvent/{eventName}?taskHub=TestHubName&connection=Storage&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
        "terminatePostUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/INSTANCEID/terminate?reason={text}&taskHub=TestHubName&connection=Storage&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
        "rewindPostUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/INSTANCEID/rewind?reason={text}&taskHub=TestHubName&connection=Storage&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
        "purgeHistoryDeleteUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/INSTANCEID?taskHub=TestHubName&connection=Storage&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
        "restartPostUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/INSTANCEID/restart?taskHub=TestHubName&connection=Storage&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
        "suspendPostUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/INSTANCEID/suspend?reason={text}&taskHub=TestHubName&connection=Storage&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
        "resumePostUri": "http://localhost:7071/runtime/webhooks/durabletask/instances/INSTANCEID/resume?reason={text}&taskHub=TestHubName&connection=Storage&code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ=="
    },
    "baseUrl": "http://localhost:7071/runtime/webhooks/durabletask",
    "requiredQueryStringParameters": "code=fMKqfur7tU1yidXikGCwP_z560dXaMhnKGsMy3RYd-bpAzFu1fnKRQ==",
    "rpcBaseUrl": "http://127.0.0.1:17071/durabletask/"
}

from azure-functions-durable-python.

crypto-ralph avatar crypto-ralph commented on July 24, 2024 1

I think I've found a way for v2 with generic_input_binding

Thanks for replying and sharing this solution. I will try your soultion next week :)

from azure-functions-durable-python.

lilyjma avatar lilyjma commented on July 24, 2024 1

Hi @AndreRicardo-Zoetis, @crypto-ralph - thank you for using Durable Functions! I'm a PM working on DF and would love to learn about your experience using the product. You can share your feedback in this quick survey to help influence what the team works on next. If you're building intelligent apps, there's also an opportunity to participate in a compensated UX study. Thanks!

from azure-functions-durable-python.

crypto-ralph avatar crypto-ralph commented on July 24, 2024

I'm particulary interested in equivalent of example "Client signals an entity" from this page:
https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-entities?tabs=function-based%2Cin-process&pivots=python#access-entities

from azure-functions-durable-python.

AndreRicardo-Zoetis avatar AndreRicardo-Zoetis commented on July 24, 2024

@davidmrdavid would you be able to help? Since you seem to be the author for the decorator that gets the starter = kwargs[parameter_name] ?

https://github.com/Azure/azure-functions-durable-python/blame/b30d0a64f7b8c1042f066006af57b74976cdf9d2/azure/durable_functions/decorators/durable_app.py#L194

from azure-functions-durable-python.

AndreRicardo-Zoetis avatar AndreRicardo-Zoetis commented on July 24, 2024

I think I've found a way for v2 with generic_input_binding

app = df.DFApp(http_auth_level=func.AuthLevel.ANONYMOUS)


# An HTTP-Triggered Function with a Durable Functions Client binding
@app.route(route="bind/")
@app.generic_input_binding(arg_name="starter", type="durableClient")
async def mybind(req: func.HttpRequest, starter):
    return starter

from azure-functions-durable-python.

AndreRicardo-Zoetis avatar AndreRicardo-Zoetis commented on July 24, 2024

I think I've found a way for v2 with generic_input_binding

Thanks for replying and sharing this solution. I will try your soultion next week :)

I've tested it locally with a v2 function app

image

Note how there is no function.json

image

from azure-functions-durable-python.

crypto-ralph avatar crypto-ralph commented on July 24, 2024

I've tested it locally with a v2 function app

I confirm that this solution works also in my case.
@AndreRicardo-Zoetis do you have any doc reference for this input binding?

I would be glad if someone from the dev team confirm that this is recommended approach as I need to introduce it in production ready system.

from azure-functions-durable-python.

AndreRicardo-Zoetis avatar AndreRicardo-Zoetis commented on July 24, 2024

I've tested it locally with a v2 function app

I confirm that this solution works also in my case. @AndreRicardo-Zoetis do you have any doc reference for this input binding?

I would be glad if someone from the dev team confirm that this is recommended approach as I need to introduce it in production ready system.

No doc reference, I was just going through code in azure-functions-durable-python until I arrived here:

For context, I was trying to find a way around #444 to call the Orchestration from FastAPI.

The code for the generic_input_binding is here:
https://github.com/Azure/azure-functions-python-library/blob/0ca53b35491ce22569f012d485c9973050ea3227/azure/functions/decorators/function_app.py#L2180

I believe I've seen first usage in this repo:
https://github.com/search?q=repo%3AAzure%2Fazure-functions-python-worker%20generic_input_binding&type=code

I was just trying to map a way from v1 to v2, because in v1 in someway is more explicit to understand where this starter comes from.

from azure-functions-durable-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.