Skip to content

Commit 52c3733

Browse files
committed
edits
1 parent eaa409c commit 52c3733

28 files changed

+211
-219
lines changed

articles/azure-cache-for-redis/cache-dotnet-core-quickstart.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: 'Quickstart: Use Azure Cache for Redis in .NET Core'
3-
description: In this quickstart, learn how to access Azure Cache for Redis in your .NET Core apps
2+
title: 'Quickstart: Use Azure Cache for Redis with .NET Core'
3+
description: Modify a sample .NET Core app and connect the app to Azure Cache for Redis.
44

55

66

@@ -10,19 +10,19 @@ ms.topic: quickstart
1010
ms.date: 03/25/2022
1111
---
1212

13-
# Quickstart: Use Azure Cache for Redis in .NET Core
13+
# Quickstart: Use Azure Cache for Redis with a .NET Core app
1414

15-
In this quickstart, you incorporate Azure Cache for Redis into a .NET Core app to have access to a secure, dedicated cache that is accessible from any application within Azure. You specifically use the [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) client with C# code in a .NET Core console app.
15+
In this quickstart, you incorporate Azure Cache for Redis into a .NET Core app to have access to a secure, dedicated cache that is accessible from any application in Azure. You specifically use the [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) client with C# code in a .NET Core console app.
1616

1717
## Skip to the code
1818

19-
This article describes how to create an app by using the Azure portal and then modify the code to end up with a working sample app.
19+
This article describes how to modify the code for a sample app to create a working app that connects to Azure Cache for Redis.
2020

21-
If you want to go straight to the code, see the [.NET Core sample](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/dotnet-core) on GitHub.
21+
If you want to go straight to the sample code, see the [.NET Core quickstart sample](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/dotnet-core) on GitHub.
2222

2323
## Prerequisites
2424

25-
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
25+
- An Azure subscription. [Create one for free](https://azure.microsoft.com/free/)
2626
- [.NET Core SDK](https://dotnet.microsoft.com/download)
2727

2828
## Create a cache
@@ -31,41 +31,41 @@ If you want to go straight to the code, see the [.NET Core sample](https://githu
3131

3232
[!INCLUDE [redis-cache-access-keys](includes/redis-cache-access-keys.md)]
3333

34-
Make a note of the values for **HOST NAME** and the **Primary** access key. You ise these values later to construct the `CacheConnection` secret.
34+
Make a note of the values for **HOST NAME** and the **Primary** access key. You use these values later to construct the `CacheConnection` secret.
3535

3636
## Add a local secret for the connection string
3737

38-
In your command window, execute the following command to store a new secret named *CacheConnection* after you replace the placeholders (including angle brackets) with your cache name (`<cache name>`) and primary access key (`<primary-access-key>`):
38+
In your command window, execute the following command to store a new secret named `CacheConnection`. Replace the placeholders (including angle brackets) with your cache name (`<cache name>`) and primary access key (`<primary-access-key>`):
3939

4040
```dos
4141
dotnet user-secrets set CacheConnection "<cache name>.redis.cache.windows.net,abortConnect=false,ssl=true,allowAdmin=true,password=<primary-access-key>"
4242
```
4343

4444
## Connect to the cache by using RedisConnection
4545

46-
The connection to your cache is managed by the `RedisConnection` class. First, you make the connection in this statement from *Program.cs*:
46+
The connection to your cache is managed by the `RedisConnection` class. First, make the connection in this statement in *Program.cs*:
4747

4848
```csharp
4949
_redisConnection = await RedisConnection.InitializeAsync(connectionString: configuration["CacheConnection"].ToString());
5050

5151
```
5252

53-
In *RedisConnection.cs*, the `StackExchange.Redis` namespace was added to the code. The namespace is required for the `RedisConnection` class.
53+
In *RedisConnection.cs*, the StackExchange.Redis namespace is added to the code. The namespace is required for the `RedisConnection` class.
5454

5555
```csharp
5656
using StackExchange.Redis;
5757

5858
```
5959

60-
The `RedisConnection` code ensures that there's always a healthy connection to the cache by managing the `ConnectionMultiplexer` instance from `StackExchange.Redis`. The `RedisConnection` class re-creates the connection when a connection is lost and unable to reconnect automatically.
60+
The `RedisConnection` class code ensures that there's always a healthy connection to the cache. The connection is managed by the `ConnectionMultiplexer` instance from StackExchange.Redis. The `RedisConnection` class re-creates the connection when a connection is lost and can't reconnect automatically.
6161

62-
For more information, see [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/) and the code in a [GitHub repo](https://github.com/StackExchange/StackExchange.Redis).
62+
For more information, see [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/) and the code in the [StackExchange.Redis GitHub repo](https://github.com/StackExchange/StackExchange.Redis).
6363

6464
<!-- :::code language="csharp" source="~/samples-cache/quickstart/dotnet-core/RedisConnection.cs"::: -->
6565

66-
## Executing cache commands
66+
## Execute cache commands
6767

68-
In `program.cs`, you can see the following code for the `RunRedisCommandsAsync` method in the `Program` class for the console application:
68+
In *Program.cs*, you can see the following code for the `RunRedisCommandsAsync` method in the `Program` class for the console application:
6969

7070
<!-- Replaced this code with lines 57-81 from dotnet-core/Program.cs -->
7171

@@ -153,13 +153,13 @@ To test serialization of .NET objects, run this command:
153153
dotnet run
154154
```
155155

156-
:::image type="content" source="media/cache-dotnet-core-quickstart/cache-console-app-complete.png" alt-text="Console app completed":::
156+
:::image type="content" source="media/cache-dotnet-core-quickstart/cache-console-app-complete.png" alt-text="Screenshot that shows a console test completed.":::
157157

158158
<!-- Clean up include -->
159159

160160
[!INCLUDE [cache-delete-resource-group](includes/cache-delete-resource-group.md)]
161161

162162
## Related content
163163

164-
- [Connection resilience](cache-best-practices-connection.md)
165-
- [Best Practices Development](cache-best-practices-development.md)
164+
- [Connection resilience best practices for your cache](cache-best-practices-connection.md)
165+
- [Development best practices for your cache](cache-best-practices-development.md)

articles/azure-cache-for-redis/cache-dotnet-how-to-use-azure-redis-cache.md

Lines changed: 41 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
title: 'Quickstart: Use Azure Cache for Redis in .NET Framework'
3-
description: In this quickstart, learn how to access Azure Cache for Redis from your .NET apps
2+
title: 'Quickstart: Use Azure Cache for Redis with .NET'
3+
description: Modify a sample .NET app and connect the app to Azure Cache for Redis.
44

55

66

@@ -9,27 +9,30 @@ ms.topic: quickstart
99
ms.custom: devx-track-csharp, mvc, mode-other, devx-track-dotnet
1010
ms.date: 03/25/2022
1111
---
12-
# Quickstart: Use Azure Cache for Redis in .NET Framework
1312

14-
In this quickstart, you incorporate Azure Cache for Redis into a .NET Framework app to have access to a secure, dedicated cache that is accessible from any application within Azure. You specifically use the [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) client with C# code in a .NET console app.
13+
# Quickstart: Use Azure Cache for Redis with a .NET app
14+
15+
In this quickstart, you incorporate Azure Cache for Redis into a .NET app to access a secure, dedicated cache that is accessible from any application in Azure. You specifically use the [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) client with C# code in a .NET console app.
1516

1617
## Skip to the code on GitHub
1718

18-
Clone the repo from [(https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/dotnet](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/dotnet) on GitHub.
19+
This article describes how to modify the code for a sample app to create a working app that connects to Azure Cache for Redis.
20+
21+
If you want to go straight to the code, see the [.NET quickstart sample](https://github.com/Azure-Samples/azure-cache-redis-samples/tree/main/quickstart/dotnet) on GitHub.
1922

2023
## Prerequisites
2124

22-
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
25+
- An Azure subscription. [Create one for free](https://azure.microsoft.com/free/)
2326
- [Visual Studio 2019](https://www.visualstudio.com/downloads/)
24-
- [.NET Framework 4 or higher](https://dotnet.microsoft.com/download/dotnet-framework), which is required by the StackExchange.Redis client.
27+
- [.NET Framework 4 or later](https://dotnet.microsoft.com/download/dotnet-framework) as required by the StackExchange.Redis client
2528

2629
## Create a cache
2730

2831
[!INCLUDE [redis-cache-create](~/reusable-content/ce-skilling/azure/includes/azure-cache-for-redis/includes/redis-cache-create.md)]
2932

3033
[!INCLUDE [redis-cache-access-keys](includes/redis-cache-access-keys.md)]
3134

32-
1. Create a file on your computer named *CacheSecrets.config* and place it *C:\AppSecrets\CacheSecrets.config*.
35+
1. Create a file on your computer named *CacheSecrets.config*. Place it in the *C:\AppSecrets\* folder.
3336

3437
1. Edit the *CacheSecrets.config* file and add the following contents:
3538

@@ -39,9 +42,9 @@ Clone the repo from [(https://github.com/Azure-Samples/azure-cache-redis-samples
3942
</appSettings>
4043
```
4144

42-
1. Replace `<host-name>` with your cache host name.
45+
- Replace `<host-name>` with your cache host name.
4346

44-
1. Replace `<access-key>` with the primary key for your cache.
47+
- Replace `<access-key>` with the primary key for your cache.
4548

4649
1. Save the file.
4750

@@ -50,17 +53,17 @@ Clone the repo from [(https://github.com/Azure-Samples/azure-cache-redis-samples
5053
<!-- this section was removed from the core sample -->
5154
In this section, you prepare the console application to use the [StackExchange.Redis](https://github.com/StackExchange/StackExchange.Redis) client for .NET.
5255

53-
1. In Visual Studio, select **Tools** > **NuGet Package Manager** > **Package Manager Console**, and run the following command from the Package Manager Console window.
56+
1. In Visual Studio, select **Tools** > **NuGet Package Manager** > **Package Manager Console**. Run the following command in the Package Manager Console window:
5457

5558
```powershell
5659
Install-Package StackExchange.Redis
5760
```
58-
59-
1. Once the installation is completed, the *StackExchange.Redis* cache client is available to use with your project.
61+
62+
1. When the installation is finished, the *StackExchange.Redis* cache client is available to use with your project.
6063

6164
## Connect to the Secrets cache
6265

63-
In Visual Studio, open your *App.config* file to verify it contains an `appSettings` `file` attribute that references the *CacheSecrets.config* file.
66+
In Visual Studio, open your *App.config* file to verify it contains an `appSettings` `file` attribute that references the *CacheSecrets.config* file:
6467

6568
```xml
6669
<?xml version="1.0" encoding="utf-8" ?>
@@ -73,36 +76,35 @@ In Visual Studio, open your *App.config* file to verify it contains an `appSetti
7376
</configuration>
7477
```
7578

76-
Never store credentials in source code. To keep this sample simple, we use an external secrets config file. A better approach would be to use [Azure Key Vault with certificates](/rest/api/keyvault/certificate-scenarios).
79+
Never store credentials in your source code. To keep this sample simple, we use an external secrets config file. A better approach would be to use [Azure Key Vault with certificates](/rest/api/keyvault/certificate-scenarios).
7780

78-
## Connect to the cache with RedisConnection
81+
## Connect to the cache by using RedisConnection
7982

80-
The connection to your cache is managed by the `RedisConnection` class. The connection is first made in this statement from `Program.cs`:
83+
The connection to your cache is managed by the `RedisConnection` class. First, make the connection in this statement in *Program.cs*:
8184

8285
```csharp
8386
_redisConnection = await RedisConnection.InitializeAsync(connectionString: ConfigurationManager.AppSettings["CacheConnection"].ToString());
8487

8588

8689
```
8790

88-
The value of the *CacheConnection* appSetting is used to reference the cache connection string from the Azure portal as the password parameter.
91+
The value of the *CacheConnection* app setting is used to reference the cache connection string from the Azure portal as the password parameter.
8992

90-
In `RedisConnection.cs`, you see the `StackExchange.Redis` namespace with the `using` keyword. This is needed for the `RedisConnection` class.
93+
In *RedisConnection.cs*, the StackExchange.Redis namespace appears as a `using` statement that the `RedisConnection` class requires:
9194

9295
```csharp
9396
using StackExchange.Redis;
9497
```
9598

96-
<!-- Is this right Philo -->
97-
The `RedisConnection` code ensures that there is always a healthy connection to the cache by managing the `ConnectionMultiplexer` instance from `StackExchange.Redis`. The `RedisConnection` class recreates the connection when a connection is lost and unable to reconnect automatically.
99+
The `RedisConnection` class code ensures that there's always a healthy connection to the cache. The connection is managed by the `ConnectionMultiplexer` instance from StackExchange.Redis. The `RedisConnection` class re-creates the connection when a connection is lost and can't reconnect automatically.
98100

99-
For more information, see [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/) and the code in a [GitHub repo](https://github.com/StackExchange/StackExchange.Redis).
101+
For more information, see [StackExchange.Redis](https://stackexchange.github.io/StackExchange.Redis/) and the code in the [StackExchange.Redis GitHub repo](https://github.com/StackExchange/StackExchange.Redis).
100102

101103
<!-- :::code language="csharp" source="~/samples-cache/quickstart/dotnet/Redistest/RedisConnection.cs"::: -->
102104

103-
## Executing cache commands
105+
## Execute cache commands
104106

105-
In `program.cs`, you can see the following code for the `RunRedisCommandsAsync` method in the `Program` class for the console application:
107+
In *Program.cs*, you can see the following code for the `RunRedisCommandsAsync` method in the `Program` class for the console application:
106108

107109
```csharp
108110
private static async Task RunRedisCommandsAsync(string prefix)
@@ -153,24 +155,25 @@ In the example, you can see the `Message` key is set to value. The app updated t
153155

154156
The Redis server stores most data as strings, but these strings can contain many types of data, including serialized binary data, which can be used when storing .NET objects in the cache.
155157

156-
Azure Cache for Redis can cache both .NET objects and primitive data types, but before a .NET object can be cached it must be serialized.
158+
Azure Cache for Redis can cache both .NET objects and primitive data types, but before a .NET object can be cached, it must be serialized.
157159

158-
This .NET object serialization is the responsibility of the application developer, and gives the developer flexibility in the choice of the serializer.
160+
This .NET object serialization is the responsibility of the application developer. You have some flexibility in your choice of the serializer.
159161

160-
One simple way to serialize objects is to use the `JsonConvert` serialization methods in `System.text.Json`.
162+
A simple way to serialize objects is to use the `JsonConvert` serialization methods in *System.text.Json*.
161163

162-
Add the `System.text.Json` namespace to Visual Studio:
164+
Add the System.text.Json namespace in Visual Studio:
163165

164166
1. Select **Tools** > **NuGet Package Manager** > *Package Manager Console**.
165167

166-
1. Then, run the following command from the Package Manager Console window.
168+
1. Then, run the following command in the Package Manager Console window:
169+
167170
```powershell
168171
Install-Package system.text.json
169172
```
170173
171-
<!-- :::image type="content" source="media/cache-dotnet-how-to-use-azure-redis-cache/cache-console-app-partial.png" alt-text="Console app partial"::: -->
174+
<!-- :::image type="content" source="media/cache-dotnet-how-to-use-azure-redis-cache/cache-console-app-partial.png" alt-text="Screenshot that shows a partial console app."::: -->
172175
173-
The following `Employee` class was defined in *Program.cs* so that the sample could also show how to get and set a serialized object :
176+
The following `Employee` class was defined in *Program.cs* so that the sample can show how to get and set a serialized object:
174177
175178
```csharp
176179
class Employee
@@ -190,31 +193,15 @@ class Employee
190193

191194
## Run the sample
192195

193-
Press **Ctrl+F5** to build and run the console app to test serialization of .NET objects.
194-
195-
:::image type="content" source="media/cache-dotnet-core-quickstart/cache-console-app-complete.png" alt-text="Console app completed":::
196-
197-
## Clean up resources
198-
199-
If you continuing to the use this quickstart, you can keep the resources created and reuse them.
200-
201-
Otherwise, if you are finished with the quickstart sample application, you can delete the Azure resources created in this quickstart to avoid charges.
202-
203-
> [!IMPORTANT]
204-
> Deleting a resource group is irreversible and that the resource group and all the resources in it are permanently deleted. Make sure that you do not accidentally delete the wrong resource group or resources. If you created the resources for hosting this sample inside an existing resource group that contains resources you want to keep, you can delete each resource individually on the left instead of deleting the resource group.
205-
>
206-
207-
Sign in to the [Azure portal](https://portal.azure.com) and select **Resource groups**.
208-
209-
In the **Filter by name...** textbox, type the name of your resource group. The instructions for this article used a resource group named *TestResources*. On your resource group in the result list, select **...** then **Delete resource group**.
196+
To build and run the console app to test serialization of .NET objects, select Ctrl+F5.
210197

211-
:::image type="content" source="media/cache-dotnet-core-quickstart/cache-delete-resource-group.png" alt-text="Delete":::
198+
:::image type="content" source="media/cache-dotnet-core-quickstart/cache-console-app-complete.png" alt-text="Screenshot that shows the console app completed.":::
212199

213-
You are asked to confirm the deletion of the resource group. Type the name of your resource group to confirm, and select **Delete**.
200+
<!-- Clean up include -->
214201

215-
After a few moments, the resource group and all of its contained resources are deleted.
202+
[!INCLUDE [cache-delete-resource-group](includes/cache-delete-resource-group.md)]
216203

217-
## Next steps
204+
## Related content
218205

219-
- [Connection resilience](cache-best-practices-connection.md)
220-
- [Best Practices Development](cache-best-practices-development.md)
206+
- [Connection resilience best practices for your cache](cache-best-practices-connection.md)
207+
- [Development best practices for your cache](cache-best-practices-development.md)

0 commit comments

Comments
 (0)