Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a1b0da0

Browse files
authored
Merge pull request #5 from yorek/v2.0
V2.0 - updated to .NET 6 and Azure Function Core Tools v4
2 parents aeb7bcf + a2a75c0 commit a1b0da0

File tree

9 files changed

+24
-36
lines changed

9 files changed

+24
-36
lines changed

‎.github/workflows/azure-static-web-apps.yml.sample‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup .NET Core
2222
uses: actions/setup-dotnet@v1
2323
with:
24-
dotnet-version: '5.0.x'
24+
dotnet-version: '6.0.x'
2525
- name: Deploy Database
2626
working-directory: ./database/deploy
2727
env:
@@ -31,7 +31,7 @@ jobs:
3131
id: builddeploy
3232
uses: Azure/static-web-apps-deploy@v1
3333
with:
34-
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PLANT_0020F4110 }}
34+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
3535
repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments)
3636
action: "upload"
3737
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
@@ -50,5 +50,5 @@ jobs:
5050
id: closepullrequest
5151
uses: Azure/static-web-apps-deploy@v1
5252
with:
53-
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_MANGO_PLANT_0020F4110 }}
53+
azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }}
5454
action: "close"

‎.vscode/settings.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"azureFunctions.deploySubpath": "api/bin/Release/netcoreapp3.1/publish",
2+
"azureFunctions.deploySubpath": "api/bin/Release/net6.0/publish",
33
"azureFunctions.projectLanguage": "C#",
44
"azureFunctions.projectRuntime": "~3",
55
"debug.internalConsoleOptions": "neverOpen",

‎.vscode/tasks.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"type": "func",
7272
"dependsOn": "build (functions)",
7373
"options": {
74-
"cwd": "${workspaceFolder}/api/bin/Debug/netcoreapp3.1"
74+
"cwd": "${workspaceFolder}/api/bin/Debug/net6.0"
7575
},
7676
"command": "host start",
7777
"isBackground": true,

‎README.md‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ In this branch the backend REST API service is modified so that the to-do list c
6969

7070
Make sure you have [Node](https://nodejs.org/en/download/) as it is required by Azure Functions Core Tools and also by Azure Static Web Apps. The backend API will be using .NET Core, but Node is needed to have the local development experience running nicely.
7171

72-
Also install the [Azure Function Core Tools v3](https://www.npmjs.com/package/azure-functions-core-tools):
72+
Also install the [Azure Function Core Tools v4](https://www.npmjs.com/package/azure-functions-core-tools):
7373

7474
```sh
75-
npm i -g azure-functions-core-tools@3 --unsafe-perm true
75+
npm i -g azure-functions-core-tools@4 --unsafe-perm true
7676
```
7777

7878
Also install the [Azure Static Web Apps CLI](https://github.com/azure/static-web-apps-cli):
7979

8080
```sh
81-
npm install -g @azure/static-web-apps-cli`
81+
npm install -g @azure/static-web-apps-cli
8282
```
8383

8484
## Create the Azure SQL database
@@ -96,7 +96,7 @@ Create a new Azure SQL database:
9696
az sql db create -g <resource-group> -s <server-name> -n todo_v2 --service-objective GP_Gen5_2
9797
```
9898

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.
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_v2` database.
100100

101101
Make sure you have the firewall configured to allow your machine to access Azure SQL:
102102

@@ -157,7 +157,7 @@ Database has been deployed successfully!
157157

158158
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 for you 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 name in the `local.settings.json`. The database name, user login and password are already set in the template file to match those used in this repository and in the `./database/sql/01-create-objects.sql` file.
159159

160-
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.
160+
To run Azure Functions locally, you might 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.
161161

162162
Make sure Azurite is running and then start the Azure Static Web App emulator:
163163

@@ -183,6 +183,10 @@ The first time the script will run will create an empty `.env` file in the sampl
183183

184184
The GitHub Token is needed as Azure Static Web App will create a GitHub action in your repository in order to automate deployment of the solution to Azure. That is right: every time you'll push a code change to your code main code branch, the application will also be re-built and deployed in Azure.
185185

186+
Make sure you set the variable `gitSource` to the address of your forked repository.
187+
188+
If you are using the `.env` file you created in `v1.0`, make sure to add the connection string to Azure SQL by creating and setting the `azureSQL` variable. You can use the same connection string you used in the `./api/local.setting.json` file to test the solution locally.
189+
186190
Run the `./azure-deploy.sh` script and the Azure Static Web app will be deployed in specified resource group. You can run the script using [WSL](https://docs.microsoft.com/en-us/windows/wsl/), or Linux or [Azure Cloud Shell](https://azure.microsoft.com/en-us/features/cloud-shell/).
187191

188192
### Adding the database to the CI/CD pipeline
@@ -201,7 +205,7 @@ Then you have to add the following code, just before the `Build And Deploy` step
201205
- name: Setup .NET Core
202206
uses: actions/setup-dotnet@v1
203207
with:
204-
dotnet-version: '5.0.x'
208+
dotnet-version: '6.0.x'
205209
- name: Deploy Database
206210
working-directory: ./database/deploy
207211
env:

‎api/api.csproj‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp3.1</TargetFramework>
3+
<TargetFramework>net6.0</TargetFramework>
44
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
55
</PropertyGroup>
66
<ItemGroup>
77
<PackageReference Include="Dapper" Version="2.0.123" />
8-
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.1" />
9-
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
8+
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.1.0" />
9+
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
1010
</ItemGroup>
1111
<ItemGroup>
1212
<None Update="host.json">

‎api/function.json‎

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎api/host.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"version": "2.0",
33
"logging": {
44
"applicationInsights": {
5-
"samplingExcludedTypes": "Request",
65
"samplingSettings": {
7-
"isEnabled": true
6+
"isEnabled": true,
7+
"excludedTypes": "Request"
88
}
99
}
1010
}

‎database/deploy/ToDo.Database.Deploy.csproj‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net5.0</TargetFramework>
5+
<TargetFramework>net6.0</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
99
<PackageReference Include="DbUp" Version="4.5.0" />
10-
<PackageReference Include="DotNetEnv" Version="2.2.0" />
11-
<PackageReference Include="Microsoft.Data.SqlClient" Version="3.0.1" />
10+
<PackageReference Include="DotNetEnv" Version="2.3.0" />
11+
<PackageReference Include="Microsoft.Data.SqlClient" Version="4.1.0" />
1212
</ItemGroup>
1313

1414
</Project>

‎database/sql/01-create-objects.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
create schema [web];
1+
create schema [web] authorization [dbo];
22
go
33

44
create user [webapp] with password = 'Super_Str0ng*P4ZZword!'

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /