Skip to content

Static web app written in React which uploads CSV files to Azure storage blobs via HTTP-triggered Azure function, which is then processed by a blob-triggered function and its results stored in yet another blob.

Notifications You must be signed in to change notification settings

hvalfangst/azure-static-react-website-triggering-functions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Static web app invoking Azure functions

This repository contains a static web app, which enables users to upload CSV files containing demographic and financial data about individuals to a designated storage blob via an HTTP-triggered Azure Function. Once uploaded to the blob, another, blob-triggered function calculates correlations between various variables, such as experience, state, gender, and income. The computed statistics are then stored in a separate storage blob. These functions are defined in the python script function_app.py - which is the main entrypoint of our Azure Function App instance.

The associated Azure infrastructure is deployed with a script (more on that below).

A branch-triggered pipeline has been set up to deploy our code to the respective Azure resources using a GitHub Actions Workflows script. The two functions are deployed using the Function App's associated publish profile, whereas the static web app is deployed using a service principal configured with a federated credential. Note that the static web app is actually hosted directly on a storage blob, which is configured to serve static websites. Thus, deploying the web app is simply a matter of uploading the files to the designated blob container.

Requirements

Allocate resources

The shell script allocate_resources creates Azure resources using the Azure CLI and a Bicep template file.

It will create the following hierarchy of resources:

graph TD
    A[Subscription]
    A --> B[Resource Group]
    B --> C[Storage Account]
    C --> D[Blob Container]
    D -->|Static Website Hosting| H[index.html]
    B --> E[App Service Plan]
    E -->|Hosts| G[Function App]
    G -->|Uses| F[Application Insights]

    A -->|Contains| B
    B -->|Contains| C
    C -->|Contains| D
    B -->|Contains| E
    B -->|Contains| F
Loading

GitHub secrets

Four secrets are required in order for the GitHub Actions Workflow script to deploy the code to the Azure resources. As may be observed in the script, these are:

  • AZURE_CLIENT_ID: Used to authenticate the service principal in order to deploy the static web app
  • AZURE_SUBSCRIPTION_ID: Used to authenticate the service principal in order to deploy the static web app
  • AZURE_TENANT_ID: Used to authenticate the service principal in order to deploy the static web app
  • PUBLISH_PROFILE: Used to deploy our two functions to the Azure Function App

img_1.png

About

Static web app written in React which uploads CSV files to Azure storage blobs via HTTP-triggered Azure function, which is then processed by a blob-triggered function and its results stored in yet another blob.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published