Skip to content

36 Upgrade Functions -> v3 #64

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d55a84e
#36 upgrade drivers => v3
DanielLarsenNZ Nov 8, 2021
a95a578
#36 upgrade Orchestrators => v3
DanielLarsenNZ Nov 8, 2021
2d48734
#36 upgrade Passengers & Trips
DanielLarsenNZ Nov 12, 2021
24f58be
#36 upgrade shared libs => dotnet 3.1
DanielLarsenNZ Nov 12, 2021
5e78db2
#36 upgrade nugets - low risk
DanielLarsenNZ Nov 12, 2021
d99f9d0
#36 refactor for new Storage Queue client SDK
DanielLarsenNZ Nov 12, 2021
75cf99f
#36 fix storage dependency
DanielLarsenNZ Nov 12, 2021
c2f8963
#36 remove Newtonsoft
DanielLarsenNZ Nov 12, 2021
157b24c
#36 upgrade SignalR
DanielLarsenNZ Nov 12, 2021
470dd83
#36 upgrade SignalR client
DanielLarsenNZ Nov 12, 2021
e7568ad
#36 upgrade SignalR server
DanielLarsenNZ Nov 12, 2021
6f4d28c
#36 upgrade identity model
DanielLarsenNZ Nov 12, 2021
3973d9c
Path filters on build actions
DanielLarsenNZ Nov 14, 2021
82e8752
Merge branch 'main' into 36-functions-v3
DanielLarsenNZ Nov 14, 2021
d94eba7
#36 upgrade Event Grid
DanielLarsenNZ Nov 14, 2021
cae9913
#36 upgrade Dapper
DanielLarsenNZ Nov 14, 2021
e994f4e
#36 upgrade Cosmos and refactor service
DanielLarsenNZ Nov 15, 2021
b0a34ee
Fix build action paths
DanielLarsenNZ Nov 15, 2021
68f2e31
Merge branch 'main' into 36-functions-v3
DanielLarsenNZ Nov 16, 2021
2c59d97
Merge branch 'refresh-functions-v4' into 36-functions-v3
DanielLarsenNZ Nov 16, 2021
d88af24
#36 run local
DanielLarsenNZ Nov 17, 2021
8242329
#36 run local
DanielLarsenNZ Nov 17, 2021
7757d5e
#36 Test local
DanielLarsenNZ Nov 22, 2021
00a659f
#36 getting started
DanielLarsenNZ Nov 23, 2021
b4dacea
#36 test local - done
DanielLarsenNZ Nov 23, 2021
f38b8c0
#36 upgrade nodejs function -> v3
DanielLarsenNZ Nov 24, 2021
389b4be
#36 Build and run SPA on localhost
DanielLarsenNZ Nov 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- '*'
paths: [ 'dotnet/**' ]
pull_request:
branches: [ main ]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- '*'
paths: [ 'nodejs/**' ]
pull_request:
branches: [ main ]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/spa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- '*'
paths: [ 'web/serverless-microservices-web/**' ]
pull_request:
branches: [ main ]

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@

# Build temp package lock
pipelines/package-lock.json

bicep/parameters.local.json
local.settings.json

2 changes: 1 addition & 1 deletion bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ var applicationInsightsName = '${applicationName}Insights'
var apimName = '${applicationName}Apim'
var sqlServerName = '${applicationName}-db'
var staticWebAppName = '${applicationName}Web'
var storageAccountName = toLower('${applicationName}functionstore')
var storageAccountName = take(toLower(replace('${applicationName}func', '-', '')), 24)
var functionsApps = [
'Trips'
'Drivers'
Expand Down
10 changes: 5 additions & 5 deletions bicep/modules/cosmosdb.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ param location string = resourceGroup().location
param databaseName string
param resourceTags object

param throughput int = 400

var containerNames = [
'main'
'archiver'
Expand All @@ -24,11 +26,6 @@ resource cosmosAccount 'Microsoft.DocumentDB/databaseAccounts@2021-06-15' = {
consistencyPolicy: {
defaultConsistencyLevel: 'Session'
}
capabilities: [
{
name: 'EnableServerless'
}
]
enableFreeTier: false
locations: [
{
Expand All @@ -53,6 +50,9 @@ resource cosmosDB 'Microsoft.DocumentDB/databaseAccounts/sqlDatabases@2021-06-15
resource: {
id: '${toLower(databaseName)}'
}
options: {
throughput: throughput
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions bicep/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
},
"secretName": "sqlAdminPassword"
}
},
"staticWebAppLocation": {
"value": "westus2"
}
}
}
16 changes: 16 additions & 0 deletions documentation/monitoring-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,22 @@ The .NET `ServerlessMicroservices.Seeder` project contains a multi-thread tester

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

```powershell
> ServerlessMicroservices.Seeder.exe testTrips --help

Usage: testTrips [options]

Options:
--help Show help information
-t|--seeddriversurl Set seed drivers url
-t|--testurl Set test url
-i|--testiterations Set test iterations
-s|--testseconds Set test seconds
-v|--signalrinfourl Set SignalR Info URL

> ServerlessMicroservices.Seeder.exe testTrips --seeddriversurl http://localhost:7071 --testurl http://localhost:7072/api/triptestparameters
```

The `testTrips` command takes 1 mandatory argument and 2 optional arguments i.e. `ServerlessMicroservices.Seeder testTrips testUrl testiterations testseconds`

- Test Parameters URL to read the test data from.
Expand Down
72 changes: 66 additions & 6 deletions documentation/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
In this document:

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

## Getting Started

In your local development environment you will need latest versions of:

* Visual Studio or VSCode
* git
* `func` CLI
* `az` CLI
* Powershell

Deploy Azure resources:

```powershell
copy bicep/parameters.json bicep/parameters.local.json
# Change params in @bicep/parameters.local.json to suit
az group create -n serverless-microservices-dev -l westus2
az deployment group create -g serverless-microservices-dev -f bicep/main.bicep -p @bicep/parameters.local.json
```

Create local settings:

``` powershell
cd dotnet
copy ServerlessMicroservices.FunctionApp.Drivers/local.settings.example.json ServerlessMicroservices.FunctionApp.Drivers/local.settings.json
copy ServerlessMicroservices.FunctionApp.Orchestrators/local.settings.example.json ServerlessMicroservices.FunctionApp.Orchestrators/local.settings.json
copy ServerlessMicroservices.FunctionApp.Passengers/local.settings.example.json ServerlessMicroservices.FunctionApp.Passengers/local.settings.json
copy ServerlessMicroservices.FunctionApp.Trips/local.settings.example.json ServerlessMicroservices.FunctionApp.Trips/local.settings.json

cd ../nodejs
copy serverless-microservices-functionapp-triparchiver/local.settings.example.json serverless-microservices-functionapp-triparchiver/local.settings.json
# Update local settings with your environment's values
```

Build and run local:

```powershell
cd scripts
./run-local.ps1
```

Integration test:

```powershell
cd scripts
./test-local.ps1
```

## Resources

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

## Provision

There are 3 ways to provision the required resources:
There are 4 ways to provision the required resources:

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

### Manual via the Portal

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

## Seeding

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.
The .NET `ServerlessMicroservices.Seeder` project contains a seeding command that can be used to seed `drivers` using the `Drivers APIs`.

**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.
**Please note** that the `seed` command will seed drivers only if there are no drivers.

> You must set the **EnableAuth** App Setting on the **Drivers** and **Passengers** Function Apps to `false` for the seeder to work.

The `seed` command takes 5 non-optional arguments i.e. `ServerlessMicroservices.Seeder.exe seed --seeddriversurl https://ridesharedrivers.azurewebsites.net --seedpassengersurl https://ridesharepassengers.azurewebsites.net`
```
> ServerlessMicroservices.Seeder.exe seed --help

Usage: seed [options]

- Drivers Function Base URL
- Passengers Function Base URL
Options:
--help Show help information
-t|--seeddriversurl Set seed drivers url
-t|--testurl Set test url
-i|--testiterations Set test iterations
-s|--testseconds Set test seconds
-v|--signalrinfourl Set SignalR Info URL

> ServerlessMicroservices.Seeder.exe seed --seeddriversurl https://ridesharedrivers.azurewebsites.net
```

## Containers

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
<!--<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.2.0" />-->
<!--<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.12" />-->
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" />
Expand All @@ -15,7 +17,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
{
"version": "2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"DocDbEndpointUri": "",
"DocDbApiKey": "",
"DocDbRideShareDatabaseName": "",
"DocDbRideShareMainCollectionName": ""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"profiles": {
"ServerlessMicroservices.FunctionApp.Orchestrators": {
"commandName": "Project",
"commandLineArgs": "start --port 7074"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="1.7.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.3" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.24" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.6.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Extensions.Logging;
using ServerlessMicroservices.Models;
using ServerlessMicroservices.Shared.Services;
Expand All @@ -15,7 +16,7 @@ public static class TripDemoOrchestrator

[FunctionName("O_DemoTrip")]
public static async Task<object> DemoTrip(
[OrchestrationTrigger] DurableOrchestrationContext context,
[OrchestrationTrigger] IDurableOrchestrationContext context,
ILogger log)
{
TripDemoState state = context.GetInput<TripDemoState>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
Expand All @@ -15,7 +16,7 @@ public static class TripDemoOrchestratorTriggers
{
[FunctionName("T_StartTripDemoViaQueueTrigger")]
public static async Task StartTripDemoViaQueueTrigger(
[OrchestrationClient] DurableOrchestrationClient context,
[DurableClient] IDurableClient context,
[QueueTrigger("%TripDemosQueue%", Connection = "AzureWebJobsStorage")] TripDemoState demoState,
ILogger log)
{
Expand All @@ -34,7 +35,7 @@ public static async Task StartTripDemoViaQueueTrigger(

[FunctionName("T_StartTripDemo")]
public static async Task<IActionResult> StartTripDemo([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "tripdemos")] HttpRequest req,
[OrchestrationClient] DurableOrchestrationClient context,
[DurableClient] IDurableClient context,
ILogger log)
{
try
Expand Down Expand Up @@ -63,7 +64,7 @@ public static async Task<IActionResult> StartTripDemo([HttpTrigger(Authorization

[FunctionName("T_GetTripDemo")]
public static async Task<IActionResult> GetTripDemo([HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "tripdemos/{code}")] HttpRequest req,
[OrchestrationClient] DurableOrchestrationClient context,
[DurableClient] IDurableClient context,
string code,
ILogger log)
{
Expand All @@ -85,7 +86,7 @@ public static async Task<IActionResult> GetTripDemo([HttpTrigger(AuthorizationLe

[FunctionName("T_TerminateTripDemo")]
public static async Task<IActionResult> TerminateTripDemo([HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "tripdemos/{code}/terminate")] HttpRequest req,
[OrchestrationClient] DurableOrchestrationClient context,
[DurableClient] IDurableClient context,
string code,
ILogger log)
{
Expand All @@ -105,7 +106,7 @@ public static async Task<IActionResult> TerminateTripDemo([HttpTrigger(Authoriza
//TODO: Implement Get Trip Demo Instances, Restart Trip Demo Instances and Terminate Trip Demo Instances if Persist to table storage if persist instances is activated

/** PRIVATE **/
private static async Task StartInstance(DurableOrchestrationClient context, TripDemoState state, string instanceId, ILogger log)
private static async Task StartInstance(IDurableOrchestrationClient context, TripDemoState state, string instanceId, ILogger log)
{
try
{
Expand All @@ -127,7 +128,7 @@ private static async Task StartInstance(DurableOrchestrationClient context, Trip
}
}

private static async Task TeminateInstance(DurableOrchestrationClient context, string instanceId, ILogger log)
private static async Task TeminateInstance(IDurableClient context, string instanceId, ILogger log)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.DurableTask;
using Microsoft.Extensions.Logging;
using ServerlessMicroservices.Models;
using ServerlessMicroservices.Shared.Helpers;
Expand All @@ -16,7 +17,7 @@ public static class TripManagerOrchestrator
{
[FunctionName("O_ManageTrip")]
public static async Task<object> ManageTrip(
[OrchestrationTrigger] DurableOrchestrationContext context,
[OrchestrationTrigger] IDurableOrchestrationContext context,
ILogger log)
{
TripItem trip = context.GetInput<TripItem>();
Expand Down
Loading