Skip to content

Commit 967afed

Browse files
authored
Merge pull request #64 from Azure-Samples/36-functions-v3
36 Upgrade Functions -> v3
2 parents f071c29 + 389b4be commit 967afed

File tree

57 files changed

+17927
-517
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+17927
-517
lines changed

.github/workflows/dotnet.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- '*'
7+
paths: [ 'dotnet/**' ]
78
pull_request:
89
branches: [ main ]
910

.github/workflows/nodejs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- '*'
7+
paths: [ 'nodejs/**' ]
78
pull_request:
89
branches: [ main ]
910

.github/workflows/spa.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- '*'
7+
paths: [ 'web/serverless-microservices-web/**' ]
78
pull_request:
89
branches: [ main ]
910

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@
1717

1818
# Build temp package lock
1919
pipelines/package-lock.json
20+
21+
bicep/parameters.local.json
22+
local.settings.json
23+

bicep/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ var applicationInsightsName = '${applicationName}Insights'
2727
var apimName = '${applicationName}Apim'
2828
var sqlServerName = '${applicationName}-db'
2929
var staticWebAppName = '${applicationName}Web'
30-
var storageAccountName = toLower('${applicationName}functionstore')
30+
var storageAccountName = take(toLower(replace('${applicationName}func', '-', '')), 24)
3131
var functionsApps = [
3232
'Trips'
3333
'Drivers'

bicep/modules/cosmosdb.bicep

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ param location string = resourceGroup().location
99
param databaseName string
1010
param resourceTags object
1111

12+
param throughput int = 400
13+
1214
var containerNames = [
1315
'main'
1416
'archiver'
@@ -24,11 +26,6 @@ resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2021-06-15' = {
2426
consistencyPolicy: {
2527
defaultConsistencyLevel: 'Session'
2628
}
27-
capabilities: [
28-
{
29-
name: 'EnableServerless'
30-
}
31-
]
3229
enableFreeTier: false
3330
locations: [
3431
{
@@ -53,6 +50,9 @@ resource cosmosDB 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2021-06-15
5350
resource: {
5451
id: '${toLower(databaseName)}'
5552
}
53+
options: {
54+
throughput: throughput
55+
}
5656
}
5757
}
5858

bicep/parameters.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
},
2222
"secretName": "sqlAdminPassword"
2323
}
24+
},
25+
"staticWebAppLocation": {
26+
"value": "westus2"
2427
}
2528
}
2629
}

documentation/monitoring-testing.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,22 @@ The .NET `ServerlessMicroservices.Seeder` project contains a multi-thread tester
1212

1313
**Please note** that the test will usually run against a deployment environment where the `AuthEnabled` setting is set to false.
1414

15+
```powershell
16+
> ServerlessMicroservices.Seeder.exe testTrips --help
17+
18+
Usage: testTrips [options]
19+
20+
Options:
21+
--help Show help information
22+
-t|--seeddriversurl Set seed drivers url
23+
-t|--testurl Set test url
24+
-i|--testiterations Set test iterations
25+
-s|--testseconds Set test seconds
26+
-v|--signalrinfourl Set SignalR Info URL
27+
28+
> ServerlessMicroservices.Seeder.exe testTrips --seeddriversurl http://localhost:7071 --testurl http://localhost:7072/api/triptestparameters
29+
```
30+
1531
The `testTrips` command takes 1 mandatory argument and 2 optional arguments i.e. `ServerlessMicroservices.Seeder testTrips testUrl testiterations testseconds`
1632

1733
- Test Parameters URL to read the test data from.

documentation/setup.md

Lines changed: 66 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
In this document:
44

55
- [Serverless Microservices reference architecture](#serverless-microservices-reference-architecture)
6+
- [Getting Started](#getting-started)
67
- [Resources](#resources)
78
- [Provision](#provision)
89
- [Manual via the Portal](#manual-via-the-portal)
@@ -67,6 +68,53 @@ In this document:
6768
- [Running in ACI](#running-in-aci)
6869
- [Running in AKS](#running-in-aks)
6970

71+
## Getting Started
72+
73+
In your local development environment you will need latest versions of:
74+
75+
* Visual Studio or VSCode
76+
* git
77+
* `func` CLI
78+
* `az` CLI
79+
* Powershell
80+
81+
Deploy Azure resources:
82+
83+
```powershell
84+
copy bicep/parameters.json bicep/parameters.local.json
85+
# Change params in @bicep/parameters.local.json to suit
86+
az group create -n serverless-microservices-dev -l westus2
87+
az deployment group create -g serverless-microservices-dev -f bicep/main.bicep -p @bicep/parameters.local.json
88+
```
89+
90+
Create local settings:
91+
92+
``` powershell
93+
cd dotnet
94+
copy ServerlessMicroservices.FunctionApp.Drivers/local.settings.example.json ServerlessMicroservices.FunctionApp.Drivers/local.settings.json
95+
copy ServerlessMicroservices.FunctionApp.Orchestrators/local.settings.example.json ServerlessMicroservices.FunctionApp.Orchestrators/local.settings.json
96+
copy ServerlessMicroservices.FunctionApp.Passengers/local.settings.example.json ServerlessMicroservices.FunctionApp.Passengers/local.settings.json
97+
copy ServerlessMicroservices.FunctionApp.Trips/local.settings.example.json ServerlessMicroservices.FunctionApp.Trips/local.settings.json
98+
99+
cd ../nodejs
100+
copy serverless-microservices-functionapp-triparchiver/local.settings.example.json serverless-microservices-functionapp-triparchiver/local.settings.json
101+
# Update local settings with your environment's values
102+
```
103+
104+
Build and run local:
105+
106+
```powershell
107+
cd scripts
108+
./run-local.ps1
109+
```
110+
111+
Integration test:
112+
113+
```powershell
114+
cd scripts
115+
./test-local.ps1
116+
```
117+
70118
## Resources
71119

72120
The following is a summary of all Azure resources required to deploy the solution:
@@ -103,11 +151,12 @@ The following is a summary of all Azure resources required to deploy the solutio
103151

104152
## Provision
105153

106-
There are 3 ways to provision the required resources:
154+
There are 4 ways to provision the required resources:
107155

108156
- [Manual via the Portal](#manual-via-the-portal)
109157
- [ARM Template](#deploy-from-arm-template)
110158
- [Cake](#cake-provision)
159+
- [Bicep](#deploy-from-bicep) (recommended)
111160

112161
### Manual via the Portal
113162

@@ -1476,16 +1525,27 @@ From a PowerShell command, use the following commands for the `Prod` environment
14761525

14771526
## Seeding
14781527

1479-
The .NET `ServerlessMicroservices.Seeder` project contains a seeding command that can be used to seed `drivers` and `passengers` using the `Drivers APIs` and `Passengers APIs`, respectively.
1528+
The .NET `ServerlessMicroservices.Seeder` project contains a seeding command that can be used to seed `drivers` using the `Drivers APIs`.
14801529

1481-
**Please note** that the `seed` command will seed drivers only if there are no drivers and will seed passengers only if there are no passengers in the solution's database.
1530+
**Please note** that the `seed` command will seed drivers only if there are no drivers.
14821531

14831532
> You must set the **EnableAuth** App Setting on the **Drivers** and **Passengers** Function Apps to `false` for the seeder to work.
14841533
1485-
The `seed` command takes 5 non-optional arguments i.e. `ServerlessMicroservices.Seeder.exe seed --seeddriversurl https://ridesharedrivers.azurewebsites.net --seedpassengersurl https://ridesharepassengers.azurewebsites.net`
1534+
```
1535+
> ServerlessMicroservices.Seeder.exe seed --help
1536+
1537+
Usage: seed [options]
14861538
1487-
- Drivers Function Base URL
1488-
- Passengers Function Base URL
1539+
Options:
1540+
--help Show help information
1541+
-t|--seeddriversurl Set seed drivers url
1542+
-t|--testurl Set test url
1543+
-i|--testiterations Set test iterations
1544+
-s|--testseconds Set test seconds
1545+
-v|--signalrinfourl Set SignalR Info URL
1546+
1547+
> ServerlessMicroservices.Seeder.exe seed --seeddriversurl https://ridesharedrivers.azurewebsites.net
1548+
```
14891549

14901550
## Containers
14911551

dotnet/ServerlessMicroservices.FunctionApp.Drivers/ServerlessMicroservices.FunctionApp.Drivers.csproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.1</TargetFramework>
4-
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
7+
<!--<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />-->
8+
<!--<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />-->
9+
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
810
</ItemGroup>
911
<ItemGroup>
1012
<ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" />
@@ -15,7 +17,7 @@
1517
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1618
</None>
1719
<None Update="local.settings.json">
18-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1921
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
2022
</None>
2123
</ItemGroup>

0 commit comments

Comments
 (0)