Skip to content

Commit 8242329

Browse files
#36 run local
1 parent d88af24 commit 8242329

File tree

16 files changed

+110
-8
lines changed

16 files changed

+110
-8
lines changed

.gitignore

+4
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+

documentation/setup.md

+26
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,32 @@ In this document:
6767
- [Running in ACI](#running-in-aci)
6868
- [Running in AKS](#running-in-aks)
6969

70+
## Getting Started
71+
72+
In your local development environment you will need latest versions of:
73+
74+
* Visual Studio or VSCode
75+
* git
76+
* `func` CLI
77+
* `az` CLI
78+
* Powershell
79+
80+
Deploy Azure resources:
81+
82+
```powershell
83+
copy bicep/parameters.json bicep/parameters.local.json
84+
# Change params in @bicep/parameters.local.json to suit
85+
az group create -n serverless-microservices-dev -l westus2
86+
az deployment group create -g serverless-microservices-dev -f bicep/main.bicep -p @bicep/parameters.local.json
87+
```
88+
89+
Build and run local:
90+
91+
```powershell
92+
cd scripts
93+
./run-local.ps1
94+
```
95+
7096
## Resources
7197

7298
The following is a summary of all Azure resources required to deploy the solution:

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1818
</None>
1919
<None Update="local.settings.json">
20-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
20+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2121
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
2222
</None>
2323
</ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
6+
"DocDbEndpointUri": "",
7+
"DocDbApiKey": "",
8+
"DocDbRideShareDatabaseName": "",
9+
"DocDbRideShareMainCollectionName": ""
10+
}
11+
}

dotnet/ServerlessMicroservices.FunctionApp.Orchestrators/ServerlessMicroservices.FunctionApp.Orchestrators.csproj

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>netcoreapp3.1</TargetFramework>
44
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
@@ -12,6 +12,9 @@
1212
<None Update="host.json">
1313
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1414
</None>
15+
<None Update="local.settings.json">
16+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
17+
</None>
1518
</ItemGroup>
1619
<ItemGroup>
1720
<ProjectReference Include="..\ServerlessMicroservices.Models\ServerlessMicroservices.Models.csproj" />
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
{
2+
"version": "2.0"
23
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
6+
"DocDbEndpointUri": "",
7+
"DocDbApiKey": "",
8+
"DocDbRideShareDatabaseName": "",
9+
"DocDbRideShareMainCollectionName": "",
10+
"TripMonitorsQueue": "trip-monitors",
11+
"TripManagersQueue": "trip-managers",
12+
"TripDemosQueue": "trip-demos",
13+
"TripDriversQueue": "trip-drivers"
14+
}
15+
}

dotnet/ServerlessMicroservices.FunctionApp.Passengers/ServerlessMicroservices.FunctionApp.Passengers.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1616
</None>
1717
<None Update="local.settings.json">
18-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
18+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
1919
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
2020
</None>
2121
</ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
{
2+
"version": "2.0"
23
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
6+
"DocDbEndpointUri": "",
7+
"DocDbApiKey": "",
8+
"DocDbRideShareDatabaseName": "",
9+
"DocDbRideShareMainCollectionName": "",
10+
"GraphTenantId": "",
11+
"GraphClientId": "",
12+
"GraphClientSecret": ""
13+
}
14+
}

dotnet/ServerlessMicroservices.FunctionApp.Trips/ServerlessMicroservices.FunctionApp.Trips.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
1919
</None>
2020
<None Update="local.settings.json">
21-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
21+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
2222
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
2323
</None>
2424
</ItemGroup>
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
{
2+
"version": "2.0"
23
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"IsEncrypted": false,
3+
"Values": {
4+
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
5+
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
6+
"DocDbEndpointUri": "",
7+
"DocDbApiKey": "",
8+
"DocDbRideShareDatabaseName": "",
9+
"DocDbRideShareMainCollectionName": ""
10+
}
11+
}

dotnet/ServerlessMicroservices.Shared/Services/UserService.cs

+2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public UserService(ISettingService settingService)
2626

2727
public UserService(string tenantId, string clientId, string clientSecret)
2828
{
29+
if (string.IsNullOrEmpty(tenantId)) throw new ArgumentNullException(nameof(tenantId), "GraphTenantId environment variable must be set before instantiating UserService.");
30+
2931
_graphUrl = GraphBaseUrl + tenantId;
3032

3133
var authority = "https://login.microsoftonline.com/" + tenantId;

scripts/run-local.ps1

+8-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ try {
44
# cd /dotnet
55
Push-Location ( Join-Path $PSScriptRoot ../dotnet ) -StackName scripts
66

7-
# Start each Function in a new console
8-
Push-Location ServerlessMicroservices.FunctionApp.Drivers
9-
Start-Process pwsh { -c func start --csharp }
7+
# Start each Function in a new console. Give each one a head start to avoid collisions building shared DLLs
8+
Start-Process pwsh { -c cd ServerlessMicroservices.FunctionApp.Drivers && func start --csharp -p 7071 }
9+
Start-Sleep -Seconds 2
10+
Start-Process pwsh { -c cd ServerlessMicroservices.FunctionApp.Trips && func start --csharp -p 7072 }
11+
Start-Sleep -Seconds 2
12+
Start-Process pwsh { -c cd ServerlessMicroservices.FunctionApp.Passengers && func start --csharp -p 7073 }
13+
Start-Sleep -Seconds 2
14+
Start-Process pwsh { -c cd ServerlessMicroservices.FunctionApp.Orchestrators && func start --csharp -p 7074 }
1015

1116
}
1217
finally {

test/local.http

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
1-
## Uses REST Client extension https://marketplace.visualstudio.com/items?itemName=humao.rest-client
1+
### Use REST Client extension https://marketplace.visualstudio.com/items?itemName=humao.rest-client
2+
3+
### Get Active Drivers
24
GET http://localhost:7071/api/activedrivers
5+
6+
### Get Active Trips
7+
GET http://localhost:7071/api/activetrips
8+
9+
### Get Passengers
10+
GET http://localhost:7071/api/passengers

0 commit comments

Comments
 (0)