Skip to content

Commit 8fa127b

Browse files
committed
Incorporated a React app with mandatory pipeline changes for building and deploying as static web app to our storage account
1 parent 975aa6e commit 8fa127b

24 files changed

+18099
-28
lines changed

.github/workflows/deploy_to_azure.yml

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ on:
99
env:
1010
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.'
1111
PYTHON_VERSION: '3.10'
12+
STORAGE_ACCOUNT_NAME: 'hvalfangststorageaccount'
1213

1314
jobs:
14-
build:
15+
build-function:
1516
runs-on: ubuntu-latest
1617
steps:
1718
- name: Checkout repository
@@ -41,13 +42,12 @@ jobs:
4142
release.zip
4243
!venv/
4344
44-
deploy:
45+
deploy-function:
4546
runs-on: ubuntu-latest
46-
needs: build
47+
needs: build-function
4748
environment:
4849
name: 'Production'
4950
url: ${{ steps.deploy-to-function.outputs.webapp-url }}
50-
5151
steps:
5252
- name: Download artifact from build job
5353
uses: actions/download-artifact@v4
@@ -66,4 +66,61 @@ jobs:
6666
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
6767
scm-do-build-during-deployment: true
6868
enable-oryx-build: true
69-
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
69+
publish-profile: ${{ secrets.PUBLISH_PROFILE }}
70+
71+
build-react:
72+
runs-on: ubuntu-latest
73+
steps:
74+
- name: Checkout repository
75+
uses: actions/checkout@v4
76+
77+
- name: Setup Node.js
78+
uses: actions/setup-node@v3
79+
with:
80+
node-version: 16
81+
82+
- name: Install dependencies
83+
run: npm install
84+
working-directory: ./client
85+
86+
- name: Build React app
87+
run: npm run build
88+
working-directory: ./client
89+
90+
- name: Zip build folder
91+
run: zip -r build.zip ./client/build
92+
93+
- name: Upload React build artifact
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: react-build
97+
path: build.zip
98+
99+
deploy-react:
100+
runs-on: ubuntu-latest
101+
needs: build-react
102+
steps:
103+
- name: Download React build artifact
104+
uses: actions/download-artifact@v4
105+
with:
106+
name: react-build
107+
108+
- name: Unzip React build
109+
run: unzip build.zip
110+
111+
- name: 'Login to Azure'
112+
uses: azure/login@v1
113+
with:
114+
creds: ${{ secrets.AZURE_CREDENTIALS }} # Use the secret where your creds are stored
115+
116+
117+
- name: Deploy React build to Azure Static Website
118+
uses: azure/CLI@v1
119+
with:
120+
azcliversion: latest
121+
inlineScript: |
122+
az storage blob upload-batch \
123+
--account-name hvalfangststorageaccount \
124+
--source ./client/build \
125+
--destination '$web' \
126+
--overwrite

README.md

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
# Python API integrated with Azure Service Bus Queue
1+
# React Web App invoking blob-triggered Azure function
2+
3+
React web app that allows users to upload csv files to an Azure Blob Storage container, which triggers an Azure Function to process the file and store the results in a separate container.
4+
The resulting data is then stored in a Cosmos DB instance, which is queried by the web app to display the data.
25

36
## Requirements
47

58
- **Platform**: x86-64, Linux/WSL
6-
- **Programming Language**: [Python 3](https://www.python.org/downloads/)
9+
- **Programming Languages**: [React](https://reactjs.org/docs/getting-started.html), [Python 3](https://www.python.org/downloads/)
710
- **Cloud Account**: [Azure](https://azure.microsoft.com/en-us/pricing/purchase-options/azure-account)
811
- **Resource provisioning**: [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/)
912

@@ -32,24 +35,9 @@ graph TD
3235
B -->|Contains| F
3336
```
3437

35-
For this script to work it is necessary to have a configuration file named **infra_config.env** in your [infra](infra) directory. It contains sensitive information
36-
such as tenant and subscription id as well as information used to reference resources. The file has been added to our [.gitignore](.gitignore) so that you don't accidentally commit it.
37-
### Structure of 'infra/infra_config.env'
38-
```bash
39-
TENANT_ID={TO_BE_SET_BY_YOU_MY_FRIEND}
40-
SUBSCRIPTION_ID={TO_BE_SET_BY_YOU_MY_FRIEND}
41-
LOCATION=northeurope
42-
RESOURCE_GROUP_NAME=hvalfangstresourcegroup
43-
STORAGE_ACCOUNT_NAME=hvalfangststorageaccount
44-
BLOB_CONTAINER_NAME=hvalfangstblobcontainer
45-
FUNCTION_APP_NAME=hvalfangstfunctionapp
46-
SERVICE_PLAN_NAME=hvalfangstserviceplan
47-
APP_INSIGHTS_NAME=hvalfangstappinsights
48-
```
49-
5038
## Deallocate resources
5139

52-
The shell script [deallocate_resources](infra/deallocate_resources.sh) deletes our Azure service bus queue, namespace and resource group.
40+
The shell script [deallocate_resources](infra/deallocate_resources.sh) deletes our Azure resources.
5341

5442
# CI/CD
5543

@@ -61,4 +49,6 @@ In order for the pipeline to work, the following secrets must be set in the repo
6149
The associated values of the aforementioned secret can be retrieved from the Azure portal, under our deployed Function App.
6250
Click on the **Get publish profile** button and copy/paste the file content into the secret value field.
6351

64-
![img_1.png](img_1.png)
52+
![img_1.png](img_1.png)
53+
54+

client/.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

0 commit comments

Comments
 (0)