Skip to content

Commit f830543

Browse files
authored
Editing pass
Made the content more consistent with our writing standards
1 parent 7d73b1c commit f830543

File tree

1 file changed

+45
-43
lines changed

1 file changed

+45
-43
lines changed

powerapps-docs/developer/common-data-service/webapi/quick-start-blazor-server-app.md

Lines changed: 45 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: "Quickstart: Web API sample (C#) (Common Data Service)| Microsoft Docs"
3-
description: "This sample demonstrates how to authenticate with a Common Data Service Server and then call a basic Web API operation, the WhoAmI Function"
2+
title: "Quickstart: Blazor Server Web API sample (C#) (Common Data Service)| Microsoft Docs"
3+
description: "This sample demonstrates how to authenticate with a Common Data Service from a Blazor Server application and then call a basic WhoAmI Web API function."
44
ms.custom: ""
5-
ms.date: 06/23/2020
5+
ms.date: 07/07/2020
66
ms.service: powerapps
77
ms.topic: "article"
88
author: "JeremyLikness" # GitHub ID
99
ms.author: "jeliknes" # MSFT alias of Microsoft employees only
10-
ms.reviewer: ""
10+
ms.reviewer: "pehecke"
1111
manager: "" # MSFT alias of manager or PM counterpart
1212
search.audienceType:
1313
- developer
@@ -19,49 +19,51 @@ search.app:
1919

2020
In this quickstart, you'll create a Blazor Server application to connect to your Common Data Service environment using the Web API.
2121

22-
You'll authenticate and use an <xref:System.Net.Http.HttpClient> to send a `GET` request to the <xref href="Microsoft.Dynamics.CRM.WhoAmI?text=WhoAmI Function" /> the response will be a <xref href="Microsoft.Dynamics.CRM.WhoAmIResponse?text=WhoAmIResponse ComplexType" />. You will display the `UserId` property value.
22+
You'll authenticate and use <xref:System.Net.Http.HttpClient> to send a `GET` request containing the [WhoAmI](/dynamics365/customer-engagement/web-api/whoami) function. The response will be a [WhoAmIResponse](/dynamics365/customer-engagement/web-api/whoamiresponse) complex type. After call completion, the `UserId` property value is displayed.
2323

2424
> [!NOTE]
25-
> This is a very simple example to show how to get connected with a minimum of code. The following [Enhanced quickstart](enhanced-quick-start.md) will build upon this sample to apply better design patterns.
25+
> This is a very simple example to show how to get connected with a minimum of code. The [Enhanced quickstart](enhanced-quick-start.md) will build upon this sample to apply better design patterns.
2626
2727
## Prerequisites
2828

29-
- Visual Studio (2019 16.6.2 recommended)
30-
- Familiarity with the Azure portal
29+
- Visual Studio 2019 (version 16.6.2 or later recommended)
30+
- Familiarity with the Microsoft Azure portal
3131
- Internet connection
3232
- Valid user account for a Common Data Service instance
33-
- Admin access to grant application registrations
33+
- Administrator access to grant application registrations
3434
- URL to the Common Data Service environment you want to connect with
3535
- Basic understanding of the Visual C# language
3636

3737
> [!NOTE]
3838
> To authenticate you must have an app registered in Azure Active Directory. The registration will happen automatically as part of the template creation, but will require additional updates in the Azure portal.
3939
40-
## Create Visual Studio project
40+
## Create a Visual Studio project
4141

42-
1. Create a new Blazor Server App using **.NET Core 3.1** - _don't_ click "Create" yet
42+
1. Create a new Blazor Server app using .NET Core 3.1 but don't choose **Create** just yet.
4343

4444
![Start a Blazor Server project](../media/quick-start-blazor-server-app-csharp-1.png)
4545

46-
1. Click "Change" under "Authentication" and choose "Work or School Accounts." Choose the appropriate dropdown. Replace `CRM520451` in the example with your organization name.
46+
1. Select **Change** under **Authentication** and then choose **Work or School Accounts**.
4747

48-
![Choose Authentication](../media/quick-start-blazor-server-app-csharp-2.png)
48+
![Choose authentication](../media/quick-start-blazor-server-app-csharp-2.png)
4949

50-
1. Click "Create"
50+
1. Choose the appropriate dropdown and then replace `CRM520451` in the example with your environment's name.
5151

52-
## Configure the Application in Active Directory
52+
1. Select **Create**.
5353

54-
By default, the template will create a registered application. Connecting to Common Data Services will require additional permissions. Open the Azure portal and log in with your credentials. Navigate to "Active Directory" and "App Registrations" and choose the entry with the same name as your application.
54+
## Configure the application in Active Directory
5555

56-
1. Choose "Authentication" and check "Access tokens" under "Implicit grant" then click "Save".
56+
By default, the template will create a registered application. Connecting to Common Data Service will require additional permissions. Open the Azure portal and log in with your credentials. Navigate to **Active Directory** and **App Registrations**, and then choose the entry with the same name as your application.
57+
58+
1. Choose **Authentication**, select (check) **Access tokens** under **Implicit grant**, and then click **Save**.
5759

5860
![Implicit grant](../media/quick-start-blazor-server-app-csharp-3.png)
5961

60-
1. Choose "Certificates & secrets" and click "New client secret"
62+
1. Choose **Certificates & secrets** and then select **New client secret**.
6163

62-
1. Give it a name (for example, "Blazor Server client") and expiration and click "Add"
64+
1. Assign the secret a name (for example, "Blazor Server client") and expiration date, and then select **Add**.
6365

64-
1. Tap the clipboard next to your secret to copy it
66+
1. Select the clipboard icon next to your secret to copy it.
6567

6668
![Copy secret](../media/quick-start-blazor-server-app-csharp-4.png)
6769

@@ -80,23 +82,23 @@ By default, the template will create a registered application. Connecting to Com
8082
}
8183
```
8284

83-
1. Open API permissions
85+
1. Navigate to **API permissions**
8486

85-
1. Click "Add a permission" and choose "Dynamics CRM"
87+
1. Select **Add a permission** and choose **Dynamics CRM**
8688

87-
1. Choose "Delegated permissions" and check `user_impersonation` then click "Add permissions"
89+
1. Choose **Delegated permissions** and select (check) **user_impersonation**, and then click **Add permissions**
8890

89-
![Add Permission](../media/quick-start-blazor-server-app-csharp-5.png)
91+
![Add permission](../media/quick-start-blazor-server-app-csharp-5.png)
9092

91-
1. Click on the newly created permission to highlight it and click "Grant admin consent for organization" (organization will have your organization name).
93+
1. Select the newly created permission to highlight it, and then shoose **Grant admin consent for organization** (your environment name is shown)
9294

93-
1. Verify the permissions have green checkboxes in the "status" column
95+
1. Verify the permissions have green checkboxes in the **status** column
9496

9597
## Prepare the app to use Azure AD tokens
9698

9799
The application requires some extra steps to capture the authentication token and pass it to the Web API request.
98100

99-
1. Right-click on the `Data` folder and add a new class named `TokenProvider`
101+
1. Right-click on the **Data** folder and add a new class named `TokenProvider`.
100102

101103
```csharp
102104
public class TokenProvider
@@ -105,14 +107,14 @@ The application requires some extra steps to capture the authentication token an
105107
}
106108
```
107109

108-
1. Open `App.razor` and add these statements to the top. Change the namespace to match the name of your application.
110+
1. Open the App.razor file and add the following statements to the top of the file. Change the namespace to match the name of your application.
109111

110112
```razor
111113
@using BlazorWebAPIExample.Data
112114
@inject TokenProvider Service
113115
```
114116

115-
1. Add a `@code` block to accept a parameter and move the token into the service
117+
1. Add a `@code` block to accept a parameter and move the token into the service.
116118

117119
```csharp
118120
[Parameter]
@@ -125,14 +127,14 @@ The application requires some extra steps to capture the authentication token an
125127
}
126128
```
127129

128-
1. Open `Pages/_Host.cshtml` and add the following using statements after the namespace declaration:
130+
1. Open the Pages/\_Host.cshtml file and add the following using statements after the namespace declaration.
129131

130132
```razor
131133
@using BlazorCommonDataService.Data
132134
@using Microsoft.AspNetCore.Authentication
133135
```
134136

135-
1. After the `<body>` tag, add the following code and update the app component to acquire and pass the token:
137+
1. After the `<body>` tag, add the following code and update the app component to acquire and pass the token.
136138

137139
```razor
138140
@{
@@ -146,21 +148,21 @@ The application requires some extra steps to capture the authentication token an
146148
</app>
147149
```
148150

149-
1. Obtain the organization name for the Common Data Services management API. If you're not sure what the name is, open the [Power Platform admin center](https://admin.powerplatform.microsoft.com/environments), navigate to "environments" then choose "open environment." You will see a URL like this: `https://{org}.crm.dynamics.com`
151+
1. Obtain the environment name for the Common Data Services management API. If you're not sure what the name is, open the [Power Platform admin center](https://admin.powerplatform.microsoft.com/environments), navigate to **Environments** then choose **Open environment**. You will see a URL like this: `https://{org}.crm.dynamics.com` where {org} is the environment name.
150152

151-
1. Add an entry to `appsettings.json` named `CDSAPI` with the URL. Add `/api/data/v.9.0/` to the end, so it looks like this:
153+
1. Add an entry named `CDSAPI` to the appsettings.json file with the environment URL as the value. Append `/api/data/v.9.0/` to the end of the URL so it looks like this:
152154

153155
```json
154156
{ "CDSAPI": "https://{org}.crm.dynamics.com/api/data/v9.0/" }
155157
```
156158

157-
1. Add this using statement to `Startup.cs`
159+
1. Add this `using` statement to the file Startup.cs.
158160

159161
```csharp
160162
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
161163
```
162164

163-
1. In the `Startup.cs` class, add registrations to retrieve the tokens and configure a client ready to use the token. Place this code between `services.AddAuthentication` and `services.AddControllersWithViews`.
165+
1. In the `Startup.cs` class, add registrations to retrieve the authentication token and configure a client ready to use the token. Place this code between `services.AddAuthentication` and `services.AddControllersWithViews`.
164166

165167
```csharp
166168
services.Configure<OpenIdConnectOptions>(AzureADDefaults.OpenIdScheme,
@@ -181,13 +183,13 @@ The application requires some extra steps to capture the authentication token an
181183
});
182184
```
183185

184-
The first registration allows requesting the token with the proper scope. The second registers the service that tracks the token, and the third creates a client with the base API address pre-configured.
186+
The first registration allows requesting the token with the proper scope. The second registers the service that tracks the token, and the third creates a client with the base API address pre-configured.
185187

186188
## Make a call to the Web API
187189

188190
Next, you'll update the `Index.razor` component to call the Web API.
189191

190-
1. Open `Index.razor` and add these statements to the top:
192+
1. Open the Index.razor file and add these statements to the top:
191193

192194
```razor
193195
@using System.Text.Json
@@ -247,7 +249,7 @@ Next, you'll update the `Index.razor` component to call the Web API.
247249
}
248250
```
249251

250-
The application is ready!
252+
The application is now ready!
251253

252254
## Run the program
253255

@@ -257,14 +259,14 @@ Press F5 to run the program. The output should look like this:
257259

258260
**Congratulations!** You have successfully connected to the Web API.
259261

260-
This quickstart sample shows a simple approach to create a Visual Studio project without any exception handling or method to refresh the access token. You can expand on the example to perform more complex operations, and wrap the `HttpClient` in a service class to handle the permissions.
262+
This quickstart sample shows a simple approach to create a Visual Studio project without any exception handling or method to refresh the access token. You can expand on the example to perform more complex operations, and wrap the `HttpClient` object in a service class to handle the permissions.
261263

262264
The [Enhanced quickstart](enhanced-quick-start.md) topic shows how to:
263265

264-
- implement exception handling methods
265-
- basic authentication method using a connection string
266-
- create a reusable method to refresh the access token
267-
- build reusable methods for data operations
266+
- Implement exception handling methods
267+
- Use basic authentication with a connection string
268+
- Create a reusable method to refresh the access token
269+
- Build reusable methods for data operations
268270

269271
## Next steps
270272

0 commit comments

Comments
 (0)