Azure / static-web-apps

Azure Static Web Apps. For bugs and feature requests, please create an issue in this repo. For community discussions, latest updates, kindly refer to the Discussions Tab. To know what's new in Static Web Apps, visit https://aka.ms/swa/ThisMonth
https://aka.ms/swa
MIT License
324 stars 56 forks source link

Use Durable Functions as backend for Static Web App #499

Open philinthecloud opened 3 years ago

philinthecloud commented 3 years ago

Describe the solution you'd like I would like my Blazor WASM front end to be able to call an Azure Durable Functions backend when deployed to Static Web Apps. This would allow me to quickly build small robust workflows with a web interface.

I have tried this and get the following error:

Error in processing api build artifacts: the file 'ConvertToXlf/function.json' has specified an invalid trigger of type 'activityTrigger' and direction ''. Currently, only httpTriggers are supported. Visit https://github.com/Azure/azure-functions-host/wiki/function.json for more information.

Describe alternatives you've considered Perhaps I can work around this by calling this particular activity function as an external "third party" endpoint from my durable functions workflow but it would be great if there were a simpler option.

Now reading about linking an existing Functions service with my static web app.

miwebst commented 3 years ago

That is correct, if you'd like to use triggers other than httpTriggers you will need to use an existing function and link them.

philinthecloud commented 3 years ago

So I have successfully deployed a Blazor WASM app as an Azure Static Web App and linked it to a separately deployed Durable Functions Workflow. From the Blazor App I can successfully start a workflow. I know this because a standard response is returned with the various Uri's for querying and stopping the workflow. Also I can see the activity in the Overview of the Azure Portal.

When I try to access the statusQueryGetUri of the Durable Functions Workflow from a normal browser window I get a Bad Request response which I assume is because the request is not authenticated.

When I try to access the statusQueryGetUri from my Blazor App using a relative Url (i.e. from /runtime... I get the error We couldn’t find that page, please check the URL and try again..

When I try to access the statusQueryGetUri from my Blazor App using a fully qualified Url (i.e. from https://... the Blazor App bombs with a CORS error.

Is it possible any url from /runtime is blocked by Static Web Apps?

mkarmark commented 3 years ago

Are your function paths prefixed with /api? Calls to the function must start with /api in order for us to recognize that call as a function request

philinthecloud commented 3 years ago

Well the out-of-the-box status calls such as /instances sit under the runtime/webhooks route but I was able to get this working by adding my own HttpTriggered function under api/ which calls methods such as IDurableOrchestrationClient.GetStatusAsync(). It's a little inconvenient to have to do this though.

anthonychu commented 3 years ago

Ah yes, I can see how this is an issue. Other triggers such as Event Grid and SignalR that rely on those webhook endpoints are also affected.