Skip to content

Commit e1cc0e8

Browse files
committed
Created web page in React which is to be hosted on my Storage Account via Static Web Sites
1 parent 975aa6e commit e1cc0e8

24 files changed

+18099
-27
lines changed

.github/workflows/deploy_to_azure.yml

Lines changed: 62 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ env:
1111
PYTHON_VERSION: '3.10'
1212

1313
jobs:
14-
build:
14+
build-function:
1515
runs-on: ubuntu-latest
1616
steps:
1717
- name: Checkout repository
@@ -41,9 +41,9 @@ jobs:
4141
release.zip
4242
!venv/
4343
44-
deploy:
44+
deploy-function:
4545
runs-on: ubuntu-latest
46-
needs: build
46+
needs: build-function
4747
environment:
4848
name: 'Production'
4949
url: ${{ steps.deploy-to-function.outputs.webapp-url }}
@@ -66,4 +66,62 @@ 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+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
115+
client-secret: ${{ secrets.AZURE_CLIENT_SECRET }}
116+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
117+
118+
- name: Deploy React build to Azure Static Website
119+
uses: azure/CLI@v1
120+
with:
121+
azcliversion: latest
122+
inlineScript: |
123+
az storage blob upload-batch \
124+
--account-name hvalfangststorageaccount \
125+
--source ./client/build \
126+
--destination '$web' \
127+
--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)