Azure Static web app vs Azure function app

BARADZA Jonathan 1 Reputation point
2022-03-02T15:44:03.023+00:00

Hie guys, i have a small scenario in which im kinda stuck , as you will see in the photo below, i have an azure static web page running separatly from the azure function app which does the logic, the user case is the client scam the QR code in which an https get request is sent to the azure function , Function app queries the Azure SQL DB for the required parameters and send them to the static web app. I have managed to set this up and its running but not the way i want.

179372-scenario.png

When i get the data from SQL DB i want to send them to the azure static page as parameters but not as url query parameters which is the current setup, i want to hide these parameters so that i dont display them on the url. Current im sending them using Get method and i dont know if i can use POST which send as a request/response body and i dont know how i should retrieve these parameters in html using JS.

So my question is how should i transfer/send my parameters from azure function to azure static web app and how to retrieve them in html page.
Any proposition will be greatly appreciated

I have seen i can work with session in azure function

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
{count} votes

1 answer

Sort by: Most helpful
  1. AnuragSingh-MSFT 21,546 Reputation points Moderator
    2022-03-03T10:18:41.22+00:00

    @BARADZA Jonathan , thank you for reaching out to us. I could not understand the architecture as available in the screenshot above. Can you please review the following image and queries and confirm if this is how it works:-

    1. I am assuming that the Http request from scanning the QR code launches a browser which takes you to the Static Web App (SWA) which in turn calls the Azure Function as an API (which queries Azure SQL DB) and returns result back to SWA. The returned result is displayed in the SWA. Please correct me if I missed something.

    179647-image.png

    2. Regarding "...data from SQL DB send them to the azure static page as parameters but not as url query parameters which is the current setup". Can you share more details about it? Please refer to this link for a sample of Azure Function acting as an API to update the content on SWA frontend. It does not show returned data in URL parameter but in the Body of HTML doc.

    If you have a working sample to support this question, that should also help us help you. You may share it via GitHub repository (after ensuring that the personal identifiable information are stripped off).
    Please let me know if you have any questions.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.