You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14-8Lines changed: 14 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,12 +52,12 @@ To run this sample in your subscription, make sure to fork the repository into y
52
52
This repo has three branches that shows the development at different stages
53
53
54
54
- 1.0: First version, no database support
55
-
- 2.0: [This branch]Database support added
56
-
- 3.0: Authentication and Authorization
55
+
- 2.0: Database support added
56
+
- 3.0: [This branch]Authentication and Authorization
57
57
58
-
### V2.0 Notes
58
+
### V3.0 Notes
59
59
60
-
In this branch the backend REST API service is modified so that the to-do list can be saved an manged using an Azure SQL database. Communication with the database is done using JSON too, as Azure SQL support [JSON natively](https://docs.microsoft.com/en-us/sql/relational-databases/json/json-data-sql-server?view=sql-server-ver15).
60
+
In this branch the backend REST API service and the database are modified so that a user can be authenticated and they will see and manage only the to-do items they have created. Anonymous access is also allowed, and all to-do items created while not authenticated will be visible and manageable by anyone. Authentication is done via the Azure Static Web Apps reverse proxy, that [takes care of all the complexities](https://docs.microsoft.com/en-us/azure/static-web-apps/authentication-authorization) of OAuth2 for you. The Vue web client has been also updated to provide login and logoff capabilities.
61
61
62
62
## Folder Structure
63
63
@@ -93,7 +93,7 @@ az sql server create -n <server-name> -l <location> --admin-user <admin-user> --
93
93
Create a new Azure SQL database:
94
94
95
95
```sh
96
-
az sql db create -g <resource-group> -s <server-name> -n todo_v2 --service-objective GP_Gen5_2
96
+
az sql db create -g <resource-group> -s <server-name> -n todo_v3 --service-objective GP_Gen5_2
97
97
```
98
98
99
99
Another option is to run the `azure-create-sql-db.sh` script in the `./databases` folder. The script uses the ARM template available in the same folder to create a server and a `todo_vw` database.
@@ -111,7 +111,7 @@ you can get your public IP from here, for example: https://ifconfig.me/
111
111
Database is deployed using [DbUp](http://dbup.github.io/). Switch to the `./database/deploy` folder and create new `.env` file containing the connection string to the created Azure SQL database. You can use the provide `.env.template` as a guide. The connection string look like:
replace the placeholder with the correct value for your database, username and password and you're good to go. Make sure the database user specified in the connection string has enough permission to create objects (for example, make sure is a server administrator or in the db_owner database role).
@@ -137,7 +137,7 @@ dotnet run
137
137
you will see something like:
138
138
139
139
```
140
-
Deploying database: todo_v2
140
+
Deploying database: todo_v3
141
141
Testing connection...
142
142
Starting deployment...
143
143
Beginning database upgrade
@@ -147,6 +147,10 @@ Executing Database Server script '01-create-objects.sql'
147
147
Checking whether journal table exists..
148
148
Creating the [dbo].[$__dbup_journal] table
149
149
The [dbo].[$__dbup_journal] table has been created
150
+
Executing Database Server script '02-update-todo-table.sql'
151
+
Executing Database Server script '03-update-stored-procs.sql'
152
+
Executing Database Server script '04-move-to-long-user-id.sql'
153
+
Executing Database Server script '05-update-stored-procs-support-long-user-id.sql'
150
154
Upgrade successful
151
155
Success!
152
156
```
@@ -155,7 +159,7 @@ Database has been deployed successfully!
155
159
156
160
## Test solution locally
157
161
158
-
Before starting the solution locally, you have to configure the Azure Function that is used to provide the backed API. In the `./api` folder create a `local.settings.json` file starting from the provided template. All you have to do is update the connection string with the value correct foryou solution. If have created the Azure SQL database as described above you'll have a database named `todo_v2`. Just make sure you add the correct server namein the `local.settings.json`. The database name, user login and password are already setin the template file to match those used in this repository and in the `./database/sql/01-create-objects.sql` file.
162
+
Before starting the solution locally, you have to configure the Azure Function that is used to provide the backed API. In the `./api` folder create a `local.settings.json` file starting from the provided template. All you have to do is update the connection string with the value correct foryou solution. If have created the Azure SQL database as described above you'll have a database named `todo_v3`. Just make sure you add the correct server namein the `local.settings.json`. The database name, user login and password are already setin the template file to match those used in this repository and in the `./database/sql/01-create-objects.sql` file.
159
163
160
164
To run Azure Functions locally, you also need a local Azure Storage emulator. You can use [Azurite](https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azurite?tabs=visual-studio) that also has a VS Code extension.
161
165
@@ -175,6 +179,8 @@ Azure Static Web Apps emulator started at http://localhost:4280. Press CTRL+C to
175
179
176
180
everything will be up and running. Go the the indicated URL and you'll see the ToDo App. Go an play with it, it will work perfectly, having the Vue.js frontend calling the REST API provided by the Azure Function and storing the to-do list in a List object.
177
181
182
+
You can also try to login and be an authenticated user. Static Web Apps will provide a mock of the real authentication process (done using the GitHub authentication provider, in this sample), so you can have a full experience also when debugging locally.
183
+
178
184
## Deploy the solution on Azure
179
185
180
186
Now that you know everything works fine, you can deploy the solution to Azure. You can take advantage of the script `./azure-deploy.sh` that will deploy the Azure Static Web app for you.
0 commit comments