Skip to content
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

Updating Readme's to default to dapr run -f . #874

Merged
merged 13 commits into from
Sep 22, 2023
138 changes: 88 additions & 50 deletions service_invocation/csharp/http/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,132 +6,170 @@ Visit [this](https://docs.dapr.io/developing-applications/building-blocks/servic

This quickstart includes one checkout service:

- Dotnet client service `checkout`
- .NET client service `checkout`

And one order processor service:

- Dotnet order-processor service `order-processor`
- .NET order-processor service `order-processor`

### Run Dotnet order-processor with Dapr
## Run all apps with multi-app run template file:

1. Open a new terminal window and navigate to `order-processor` directory and install dependencies:
This section shows how to run all applications at once using [multi-app run template files](https://docs.dapr.io/developing-applications/local-development/multi-app-dapr-run/multi-app-overview/) along with `dapr run -f .`. This is a quick and easy approach to test or debug interactions with multiple applications.
paulyuk marked this conversation as resolved.
Show resolved Hide resolved

1. Open a new terminal window and install dependencies for `order-processor` and `checkout` apps:

<!-- STEP
name: Install Dotnet dependencies
name: Install Dotnet dependencies for order-processor and checkout
-->

```bash
cd ./order-processor
dotnet restore
dotnet build
cd ../checkout
dotnet restore
```

<!-- END_STEP -->

2. Run the Dotnet order-processor app with Dapr:
2. Run `order-processor` and `checkout` using the multi app run template defined in [dapr.yaml](./dapr.yaml):

<!-- STEP
name: Run order-processor service
name: Run multi app run template
expected_stdout_lines:
- '== APP == Order received : Order { orderId = 10 }'
- "Exited App successfully"
- 'This is a preview feature and subject to change in future releases'
- 'Validating config and starting app "order-processor"'
- 'Started Dapr with app id "order-processor"'
- 'Writing log files to directory'
- 'Validating config and starting app "checkout"'
- 'Started Dapr with app id "checkout"'
- 'Writing log files to directory'
- '== APP - order-processor == Order received : Order { orderId = 12 }'
- '== APP - checkout == Order passed: Order { OrderId = 12 }'
expected_stderr_lines:
output_match_mode: substring
background: true
sleep: 10
sleep: 15
timeout_seconds: 60
-->

```bash
cd ./order-processor
dapr run --app-port 7001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- dotnet run
dapr run -f .
```

The terminal console output should look similar to this:

```text
== APP - order-processor == Order received : Order { orderId = 1 }
== APP - checkout == Order passed: Order { OrderId = 1 }
== APP - order-processor == Order received : Order { orderId = 2 }
== APP - checkout == Order passed: Order { OrderId = 2 }
== APP - order-processor == Order received : Order { orderId = 3 }
== APP - checkout == Order passed: Order { OrderId = 3 }
== APP - order-processor == Order received : Order { orderId = 4 }
== APP - checkout == Order passed: Order { OrderId = 4 }
== APP - order-processor == Order received : Order { orderId = 5 }
== APP - checkout == Order passed: Order { OrderId = 5 }
== APP - order-processor == Order received : Order { orderId = 6 }
== APP - checkout == Order passed: Order { OrderId = 6 }
== APP - order-processor == Order received : Order { orderId = 7 }
== APP - checkout == Order passed: Order { OrderId = 7 }
== APP - order-processor == Order received : Order { orderId = 8 }
== APP - checkout == Order passed: Order { OrderId = 8 }
== APP - order-processor == Order received : Order { orderId = 9 }
== APP - checkout == Order passed: Order { OrderId = 9 }
== APP - order-processor == Order received : Order { orderId = 10 }
== APP - checkout == Order passed: Order { OrderId = 10 }
== APP - order-processor == Order received : Order { orderId = 11 }
== APP - checkout == Order passed: Order { OrderId = 11 }
== APP - order-processor == Order received : Order { orderId = 12 }
== APP - checkout == Order passed: Order { OrderId = 12 }
```

3. Stop and clean up application processes

```bash
dapr stop -f .
```
<!-- END_STEP -->

### Run Dotnet checkout with Dapr
## Run a single app at a time with Dapr (Optional)

1. Open a new terminal window and navigate to the `checkout` directory and install dependencies:
An altnerative to running all or multiple applications at once is to run single apps one-at-a-time using multiple `dapr run .. -- dotnet run` commands. This next section covers how to do this.

### Run .NET `order-processor` with Dapr


1. Open a new terminal window and navigate to `order-processor` directory and install dependencies:

<!-- STEP
name: Install Dotnet dependencies
-->

```bash
cd ./checkout
cd ./order-processor
dotnet restore
dotnet build
```

<!-- END_STEP -->

2. Run the Dotnet checkout app with Dapr:
2. Run the Dotnet order-processor app with Dapr:

<!-- STEP
name: Run checkout service
name: Run order-processor service
expected_stdout_lines:
- '== APP == Order passed: Order { OrderId = 1 }'
- '== APP == Order passed: Order { OrderId = 2 }'
- '== APP == Order received : Order { orderId = 10 }'
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
background: true
sleep: 10
-->

```bash
cd ./checkout
dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- dotnet run
cd ./order-processor
dapr run --app-port 7001 --app-id order-processor --app-protocol http --dapr-http-port 3501 -- dotnet run
```

<!-- END_STEP -->

```bash
dapr stop --app-id order-processor
```

### Start all apps with multi app run template file:
### Run .NET `checkout` with Dapr

1. Open a new terminal window and install dependencies for `order-processor` and `checkout` apps:
1. Open a new terminal window and navigate to the `checkout` directory and install dependencies:

<!-- STEP
name: Install Dotnet dependencies for order-processor and checkout
name: Install Dotnet dependencies
-->

```bash
cd ./order-processor
dotnet restore
dotnet build
cd ../checkout
cd ./checkout
dotnet restore
dotnet build
```

<!-- END_STEP -->

2. Run the multi app run template:
2. Run the Dotnet checkout app with Dapr:

<!-- STEP
name: Run multi app run template
name: Run checkout service
expected_stdout_lines:
- 'This is a preview feature and subject to change in future releases'
- 'Validating config and starting app "order-processor"'
- 'Started Dapr with app id "order-processor"'
- 'Writing log files to directory'
- 'Validating config and starting app "checkout"'
- 'Started Dapr with app id "checkout"'
- 'Writing log files to directory'
- '== APP == Order passed: Order { OrderId = 1 }'
- '== APP == Order passed: Order { OrderId = 2 }'
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
background: true
sleep: 15
sleep: 10
timeout_seconds: 60
-->

```bash
dapr run -f .
cd ./checkout
dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 -- dotnet run
```

<!-- END_STEP -->

3. Stop and clean up application processes
```bash
dapr stop -f .
```
dapr stop --app-id order-processor
```
<!-- END_STEP -->