Skip to content

Commit 9bc0486

Browse files
guardrexRick-Anderson
authored andcommitted
Fix and match tab groups in GRPC topic (#13984)
* Fix and match tab groups in GRPC topic * Revert combined * Fix tab heading levels * Good grief! lol
1 parent 3534002 commit 9bc0486

File tree

1 file changed

+46
-42
lines changed

1 file changed

+46
-42
lines changed

aspnetcore/tutorials/grpc/grpc-start.md

+46-42
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ author: juntaoluo
44
description: This tutorial shows how to create a gRPC Service and gRPC client on ASP.NET Core. Learn how to create a gRPC Service project, edit a proto file, and add a duplex streaming call.
55
monikerRange: '>= aspnetcore-3.0'
66
ms.author: johluo
7-
ms.date: 8/22/2019
7+
ms.date: 8/23/2019
88
uid: tutorials/grpc/grpc-start
99
---
1010
# Tutorial: Create a gRPC client and server in ASP.NET Core
@@ -45,13 +45,15 @@ In this tutorial, you:
4545
# [Visual Studio](#tab/visual-studio)
4646

4747
* Start Visual Studio and select **Create a new project**. Alternatively, from the Visual Studio **File** menu, select **New** > **Project**.
48-
* In the **Create a new project** dialog, select **gPRC Service** and select **Next**.
48+
* In the **Create a new project** dialog, select **gPRC Service** and select **Next**:
49+
4950
![**Create a new project** dialog](~/tutorials/grpc/grpc-start/static/cnp.png)
51+
5052
* Name the project **GrpcGreeter**. It's important to name the project *GrpcGreeter* so the namespaces will match when you copy and paste code.
51-
* Select **Create**
53+
* Select **Create**.
5254
* In the **Create a new gRPC service** dialog:
5355
* The **gRPC Service** template is selected.
54-
* Select **Create**
56+
* Select **Create**.
5557

5658
# [Visual Studio Code](#tab/visual-studio-code)
5759

@@ -68,7 +70,7 @@ In this tutorial, you:
6870
* The `code` command opens the *GrpcGreeter* folder in a new instance of Visual Studio Code.
6971

7072
A dialog box appears with **Required assets to build and debug are missing from 'GrpcGreeter'. Add them?**
71-
* Select **Yes**
73+
* Select **Yes**.
7274

7375
# [Visual Studio for Mac](#tab/visual-studio-mac)
7476

@@ -83,9 +85,7 @@ The preceding commands use the [.NET Core CLI](/dotnet/core/tools/dotnet) to cre
8385

8486
### Open the project
8587

86-
From Visual Studio, select **File > Open**, and then select the *GrpcGreeter.sln* file.
87-
88-
<!-- End of VS tabs -->
88+
From Visual Studio, select **File** > **Open**, and then select the *GrpcGreeter.sln* file.
8989

9090
---
9191

@@ -97,11 +97,13 @@ From Visual Studio, select **File > Open**, and then select the *GrpcGreeter.sln
9797

9898
Visual Studio runs the service in a command prompt.
9999

100-
# [Visual Studio Code / Visual Studio for Mac](#tab/visual-studio-code+visual-studio-mac)
100+
# [Visual Studio Code](#tab/visual-studio-code)
101101

102102
* Run the gRPC Greeter project *GrpcGreeter* from the command line using `dotnet run`.
103103

104-
<!-- End of combined VS/Mac tabs -->
104+
# [Visual Studio for Mac](#tab/visual-studio-mac)
105+
106+
* Run the gRPC Greeter project *GrpcGreeter* from the command line using `dotnet run`.
105107

106108
---
107109

@@ -125,15 +127,15 @@ info: Microsoft.Hosting.Lifetime[0]
125127

126128
*GrpcGreeter* project files:
127129

128-
* *greet.proto*: The *Protos/greet.proto* file defines the `Greeter` gRPC and is used to generate the gRPC server assets. For more information, see [Introduction to gRPC](xref:grpc/index).
130+
* *greet.proto* &ndash; The *Protos/greet.proto* file defines the `Greeter` gRPC and is used to generate the gRPC server assets. For more information, see [Introduction to gRPC](xref:grpc/index).
129131
* *Services* folder: Contains the implementation of the `Greeter` service.
130-
* *appSettings.json*: Contains configuration data, such as protocol used by Kestrel. For more information, see <xref:fundamentals/configuration/index>.
131-
* *Program.cs*: Contains the entry point for the gRPC service. For more information, see <xref:fundamentals/host/generic-host>.
132-
* *Startup.cs*: Contains code that configures app behavior. For more information, see [App startup](xref:fundamentals/startup).
132+
* *appSettings.json* &ndash; Contains configuration data, such as protocol used by Kestrel. For more information, see <xref:fundamentals/configuration/index>.
133+
* *Program.cs* &ndash; Contains the entry point for the gRPC service. For more information, see <xref:fundamentals/host/generic-host>.
134+
* *Startup.cs* &ndash; Contains code that configures app behavior. For more information, see [App startup](xref:fundamentals/startup).
133135

134136
## Create the gRPC client in a .NET console app
135137

136-
## [Visual Studio](#tab/visual-studio)
138+
# [Visual Studio](#tab/visual-studio)
137139

138140
* Open a second instance of Visual Studio and select **Create a new project**.
139141
* In the **Create a new project** dialog, select **Console App (.NET Core)** and select **Next**.
@@ -145,16 +147,14 @@ info: Microsoft.Hosting.Lifetime[0]
145147
* Change directories (`cd`) to a folder which will contain the project.
146148
* Run the following commands:
147149

148-
```console
149-
dotnet new console -o GrpcGreeterClient
150-
code -r GrpcGreeterClient
151-
```
150+
```console
151+
dotnet new console -o GrpcGreeterClient
152+
code -r GrpcGreeterClient
153+
```
152154

153155
# [Visual Studio for Mac](#tab/visual-studio-mac)
154156

155-
Follow the instructions [here](/dotnet/core/tutorials/using-on-mac-vs-full-solution) to create a console app with the name *GrpcGreeterClient*.
156-
157-
<!-- End of VS tabs -->
157+
Follow the instructions in [Building a complete .NET Core solution on macOS using Visual Studio for Mac](/dotnet/core/tutorials/using-on-mac-vs-full-solution) to create a console app with the name *GrpcGreeterClient*.
158158

159159
---
160160

@@ -166,7 +166,7 @@ The gRPC client project requires the following packages:
166166
* [Google.Protobuf](https://www.nuget.org/packages/Google.Protobuf/), which contains protobuf message APIs for C#.
167167
* [Grpc.Tools](https://www.nuget.org/packages/Grpc.Tools/), which contains C# tooling support for protobuf files. The tooling package isn't required at runtime, so the dependency is marked with `PrivateAssets="All"`.
168168

169-
### [Visual Studio](#tab/visual-studio)
169+
# [Visual Studio](#tab/visual-studio)
170170

171171
Install the packages using either the Package Manager Console (PMC) or Manage NuGet Packages.
172172

@@ -176,11 +176,11 @@ Install the packages using either the Package Manager Console (PMC) or Manage Nu
176176
* From the **Package Manager Console** window, run `cd GrpcGreeterClient` to change directories to the folder containing the *GrpcGreeterClient.csproj* files.
177177
* Run the following commands:
178178

179-
```powershell
180-
Install-Package Grpc.Net.Client -prerelease
181-
Install-Package Google.Protobuf -prerelease
182-
Install-Package Grpc.Tools -prerelease
183-
```
179+
```powershell
180+
Install-Package Grpc.Net.Client -prerelease
181+
Install-Package Google.Protobuf -prerelease
182+
Install-Package Grpc.Tools -prerelease
183+
```
184184

185185
#### Manage NuGet Packages option to install packages
186186

@@ -190,7 +190,7 @@ Install-Package Grpc.Tools -prerelease
190190
* Select the **Grpc.Net.Client** package from the **Browse** tab and select **Install**.
191191
* Repeat for `Google.Protobuf` and `Grpc.Tools`.
192192

193-
### [Visual Studio Code](#tab/visual-studio-code)
193+
# [Visual Studio Code](#tab/visual-studio-code)
194194

195195
Run the following commands from the **Integrated Terminal**:
196196

@@ -200,7 +200,7 @@ dotnet add GrpcGreeterClient.csproj package Google.Protobuf
200200
dotnet add GrpcGreeterClient.csproj package Grpc.Tools
201201
```
202202

203-
### [Visual Studio for Mac](#tab/visual-studio-mac)
203+
# [Visual Studio for Mac](#tab/visual-studio-mac)
204204

205205
* Right-click the **Packages** folder in **Solution Pad** > **Add Packages**
206206
* Enter **Grpc.Net.Client** in the search box.
@@ -223,15 +223,15 @@ dotnet add GrpcGreeterClient.csproj package Grpc.Tools
223223

224224
Select the *GrpcGreeterClient.csproj* file.
225225

226-
# [Visual Studio for Mac](#tab/visual-studio-mac
226+
# [Visual Studio for Mac](#tab/visual-studio-mac)
227227

228-
Right-click the project and select **Tools > Edit File**.
228+
Right-click the project and select **Tools** > **Edit File**.
229229

230230
---
231231

232-
* Add an item group with a `<Protobuf>` element that refers to the **greet.proto** file:
232+
* Add an item group with a `<Protobuf>` element that refers to the *greet.proto* file:
233233

234-
```XML
234+
```xml
235235
<ItemGroup>
236236
<Protobuf Include="Protos\greet.proto" GrpcServices="Client" />
237237
</ItemGroup>
@@ -243,7 +243,7 @@ Build the project to create the types in the `GrpcGreeter` namespace. The `GrpcG
243243

244244
Update the gRPC client *Program.cs* file with the following code:
245245

246-
[!code-cs[](~/tutorials/grpc/grpc-start/sample/GrpcGreeterClient/Program.cs?name=snippet2)]
246+
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/GrpcGreeterClient/Program.cs?name=snippet2)]
247247

248248
*Program.cs* contains the entry point and logic for the gRPC client.
249249

@@ -252,36 +252,40 @@ The Greeter client is created by:
252252
* Instantiating an `HttpClient` containing the information for creating the connection to the gRPC service.
253253
* Using the `HttpClient` to construct the Greeter client:
254254

255-
[!code-cs[](~/tutorials/grpc/grpc-start/sample/GrpcGreeterClient/Program.cs?name=snippet&highlight=3-6)]
255+
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/GrpcGreeterClient/Program.cs?name=snippet&highlight=3-6)]
256256

257257
The Greeter client calls the asynchronous `SayHello` method. The result of the `SayHello` call is displayed:
258258

259-
[!code-cs[](~/tutorials/grpc/grpc-start/sample/GrpcGreeterClient/Program.cs?name=snippet&highlight=7-9)]
259+
[!code-csharp[](~/tutorials/grpc/grpc-start/sample/GrpcGreeterClient/Program.cs?name=snippet&highlight=7-9)]
260260

261261
## Test the gRPC client with the gRPC Greeter service
262262

263-
### [Visual Studio](#tab/visual-studio)
263+
# [Visual Studio](#tab/visual-studio)
264264

265265
* In the Greeter service, press `Ctrl+F5` to start the server without the debugger.
266266
* In the `GrpcGreeterClient` project, press `Ctrl+F5` to start the client without the debugger.
267267

268-
### [Visual Studio Code / Visual Studio for Mac](#tab/visual-studio-code+visual-studio-mac)
268+
# [Visual Studio Code](#tab/visual-studio-code)
269269

270270
* Start the Greeter service.
271271
* Start the client.
272272

273-
<!-- End of combined VS/Mac tabs -->
273+
274+
# [Visual Studio for Mac](#tab/visual-studio-mac)
275+
276+
* Start the Greeter service.
277+
* Start the client.
274278

275279
---
276280

277-
The client sends a greeting to the service with a message containing its name "GreeterClient". The service sends the message "Hello GreeterClient" as a response. The "Hello GreeterClient" response is displayed in the command prompt:
281+
The client sends a greeting to the service with a message containing its name, *GreeterClient*. The service sends the message "Hello GreeterClient" as a response. The "Hello GreeterClient" response is displayed in the command prompt:
278282

279283
```console
280284
Greeting: Hello GreeterClient
281285
Press any key to exit...
282286
```
283287

284-
The gRPC service records the details of the successful call in the logs written to the command prompt.
288+
The gRPC service records the details of the successful call in the logs written to the command prompt:
285289

286290
```console
287291
info: Microsoft.Hosting.Lifetime[0]

0 commit comments

Comments
 (0)