Skip to content

Commit 9443133

Browse files
committed
edit pass: comm-service-tutorials
1 parent c4f5f12 commit 9443133

File tree

3 files changed

+78
-73
lines changed

3 files changed

+78
-73
lines changed
Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Trusted Service JavaScript
3-
description: This is the JavaScript version of creating a Trusted Service for Communication Services.
3+
description: This article describes the JavaScript version of creating a Trusted Service for Azure Communication Services.
44
author: tophpalmer
55
manager: nimag
66
services: azure-communication-services
@@ -10,42 +10,44 @@ ms.topic: include
1010
ms.service: azure-communication-services
1111
---
1212

13-
## Download Code
13+
## Download code
1414

15-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-javascript-quickstarts/tree/main/trusted-authentication-service)
15+
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-javascript-quickstarts/tree/main/trusted-authentication-service).
1616

1717
## Prerequisites
1818

19-
- An Azure account with an active subscription. For details, see [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
19+
- An Azure account with an active subscription. If you don't have an Azure subscription, you can [create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
2020
- [Visual Studio Code](https://code.visualstudio.com/) on one of the [supported platforms](https://code.visualstudio.com/docs/supporting/requirements#_platforms).
2121
- [Node.js](https://nodejs.org/), Active LTS and Maintenance LTS versions (10.14.1 recommended). Use the `node --version` command to check your version.
2222
- The [Azure Functions extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions) for Visual Studio Code.
23-
- An active Communication Services resource and connection string. [Create a Communication Services resource](../../quickstarts/create-communication-resource.md).
23+
- An active Communication Services resource and connection string. For more information, see [Quickstart: Create and manage Communication Services resources](../../quickstarts/create-communication-resource.md).
2424

2525
## Overview
2626

27-
:::image type="content" source="../media/trusted-service-architecture.png" alt-text="Diagram for trusted service architecture":::
27+
:::image type="content" source="../media/trusted-service-architecture.png" alt-text="Diagram that shows trusted service architecture.":::
2828

29-
For this tutorial we'll be creating an Azure Function that will serve as a trusted token provisioning service. You can use this tutorial to bootstrap your own token provisioning service.
29+
For this tutorial, you create a function app that serves as a trusted token provisioning service. You can use this tutorial to bootstrap your own token provisioning service.
3030

31-
This service is responsible for authenticating users to Azure Communication Services. Users of your Communication Services applications will require an `Access Token` in order to participate in chat threads and VoIP calls. The Azure Function will work as a trusted middleman between the user and the Communication Services. This allows you to provision access tokens without exposing your resource connection string to your users.
31+
This service is responsible for authenticating users to Communication Services. Users of your Communication Services applications require an access token to participate in chat threads and VoIP calls. The function works as a trusted middleman between the user and Communication Services. You can provision access tokens without exposing your resource connection string to your users.
3232

3333
For more information, see the [client-server architecture](../../concepts/identity-model.md#client-server-architecture) and [authentication and authorization](../../concepts/authentication.md) conceptual documentation.
3434

35-
## Setting up
35+
## Setup
3636

37-
### Azure Functions set up
37+
This section describes the procedures to set up a function.
3838

39-
Let's first set up the basic structure for our Azure function. Step by step instructions on the set up can be found here: [Create a function using Visual Studio Code](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript)
39+
### Azure Functions setup
4040

41-
Our Azure Function requires the following configuration:
41+
Let's first set up the basic structure for the function. For step-by-step instructions for setup, see [Quickstart: Create a C# function in Azure by using Visual Studio Code](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript).
4242

43-
- Language: JavaScript
44-
- Template: HTTP Trigger
45-
- Authorization Level: Anonymous (This can be switched later if you prefer a different authorization model)
46-
- Function Name: User defined
43+
The function requires the following configuration:
4744

48-
After following the [Azure Functions instructions](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript) with the above configuration, you should have a project in Visual Studio Code for the Azure Function with an `index.js` file that contains the function itself. The code inside of this file should be as follows:
45+
- **Language**: JavaScript
46+
- **Template**: HTTP Trigger
47+
- **Authorization Level**: Anonymous (if you prefer a different authorization model, you can switch it later)
48+
- **Function Name**: User defined
49+
50+
After you follow the instructions in [Quickstart: Create a C# function in Azure by using Visual Studio Code](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript) with the preceding configuration, you should have a project in Visual Studio Code for the function with an `index.js` file that contains the function itself. The following code inside of the file should be:
4951

5052
```javascript
5153

@@ -65,43 +67,43 @@ module.exports = async function (context, req) {
6567

6668
```
6769

68-
We'll now proceed to install Azure Communication Services libraries.
70+
The next step is to install Communication Services libraries.
6971

70-
### Install communication services libraries
72+
### Install Communication Services libraries
7173

72-
We'll use the `Identity` library to generate `User Access Tokens`.
74+
You use the `Identity` library to generate user access tokens.
7375

74-
Use the `npm install` command to install the Azure Communication Services Identity SDK for JavaScript.
76+
Use the `npm install` command to install the Communication Services Identity SDK for JavaScript.
7577

7678
```console
7779

7880
npm install @azure/communication-identity --save
7981

8082
```
8183

82-
The `--save` option lists the library as a dependency in your **package.json** file.
84+
The `--save` option lists the library as a dependency in your *package.json* file.
8385

84-
At the top of the `index.js` file, import the interface for the `CommunicationIdentityClient`
86+
At the top of the `index.js` file, import the interface for the `CommunicationIdentityClient` parameter.
8587

8688
```javascript
8789
const { CommunicationIdentityClient } = require('@azure/communication-identity');
8890
```
8991

90-
## Access token generation
92+
## Generate access tokens
9193

92-
To allow our Azure Function to generate `User Access Tokens`, we'll first need use the connection string for our Communication Services resource.
94+
To allow your function to generate user access tokens, you first need to use the connection string for your Communication Services resource.
9395

94-
Visit the [resource provisioning quickstart](../../quickstarts/create-communication-resource.md) for more information on retrieving your connection string.
96+
For more information on how to retrieve your connection string, see [Quickstart: Create and manage Communication Services resources](../../quickstarts/create-communication-resource.md).
9597

9698
``` javascript
9799
const connectionString = 'INSERT YOUR RESOURCE CONNECTION STRING'
98100
```
99101

100-
Next, we'll modify our original function to generate `User Access Tokens`.
102+
Next, you modify your original function to generate user access tokens.
101103

102-
`User Access Tokens` are generated by creating a user from the `createUser` method. Once the user is created we can use the `getToken` method to generate a token for that user which the Azure Function returns.
104+
To generate user access tokens, use the `createUser` method to create a user. After the user is created, use the `getToken` method to generate a token for that user, which the function returns.
103105

104-
For this example, we will configure the token scope to `voip`. Other scopes might be necessary for your application. Learn more about [scopes](../../quickstarts/identity/access-tokens.md)
106+
For this example, you configure the token scope to `voip`. Other scopes might be necessary for your application. To learn more about scopes, see [Create and manage access tokens](../../quickstarts/identity/access-tokens.md).
105107

106108
```javascript
107109
module.exports = async function (context, req) {
@@ -117,31 +119,32 @@ module.exports = async function (context, req) {
117119
}
118120
```
119121

120-
For existing Communication Services `CommunicationUser`, you can skip the creation step and just generate an access token. More details found in the [Create user access tokens quickstart](../../quickstarts/identity/access-tokens.md).
122+
For the existing Communication Services `CommunicationUser` parameter, you can skip the creation step and generate an access token. For more information, see [Create and manage access tokens](../../quickstarts/identity/access-tokens.md).
123+
124+
## Test the function
121125

122-
## Test the Azure Function
126+
Run the function locally by using `F5`. This action initializes the function locally and makes it accessible through `http://localhost:7071/api/FUNCTION_NAME`. For more information on running locally, see [Quickstart: Create a C# function in Azure by using Visual Studio Code](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript#run-the-function-locally).
123127

124-
Run the Azure Function locally using `F5`. This will initialize the Azure Function locally and make it accessible through: `http://localhost:7071/api/FUNCTION_NAME`. Check out additional documentation on [running locally](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript#run-the-function-locally)
128+
Open the URL on your browser and you see a response body with the Communication User ID, the token, and the expiration for the token.
125129

126-
Open the URL on your browser and you should see a response body with the Communication User ID, token and expiration for the token.
130+
:::image type="content" source="../media/trusted-service-sample-response.png" alt-text="Screenshot that shows a response example for the created function.":::
127131

128-
:::image type="content" source="../media/trusted-service-sample-response.png" alt-text="Screenshot showing a Response example for the created Azure Function.":::
132+
## Deploy the function to Azure
129133

130-
## Deploy the Function to Azure
134+
To deploy your function, follow the step-by-step instructions in [Quickstart: Create a C# function in Azure by using Visual Studio Code](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript#sign-in-to-azure).
131135

132-
To deploy your Azure Function, you can follow [step by step instructions](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript#sign-in-to-azure)
136+
In summary, you need to:
133137

134-
In summary, you will need to:
135-
1. Sign in to Azure from Visual Studio
136-
2. Publish your project to your Azure account. Here you will need to choose an existing subscription.
137-
3. Create a new Azure Function resource using the Visual Studio wizard or use an existing resource. For a new resource, you will need to configure it to your desired region, runtime and unique identifier.
138-
4. Wait for deployment to finalize
139-
5. Run the function 🎉
138+
1. Sign in to Azure from Visual Studio.
139+
1. Publish your project to your Azure account. Here you need to choose an existing subscription.
140+
1. Create a new function resource by using the Visual Studio wizard or an existing resource. For a new resource, you need to configure it to your desired region, runtime, and unique identifier.
141+
1. Wait for deployment to finalize.
142+
1. Run the function.
140143

141-
## Run Azure Function
144+
## Run the function
142145

143-
Run the Azure function using the url `http://<function-appn-ame>.azurewebsites.net/api/<function-name>`
146+
Run the function by using the URL `http://<function-appn-ame>.azurewebsites.net/api/<function-name>`.
144147

145-
You can find the URL by right clicking the function on Visual Studio Code and copying the Function URL.
148+
To find the URL, right-click the function in Visual Studio Code and copy the function URL.
146149

147-
For more information on [running your Azure function](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript#run-the-function-in-azure)
150+
For more information on how to run your function, see [Quickstart: Create a C# function in Azure by using Visual Studio Code](../../../azure-functions/create-first-function-vs-code-csharp.md?pivots=programming-language-javascript#run-the-function-in-azure).

0 commit comments

Comments
 (0)