You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/redis/go-get-started.md
+15-14Lines changed: 15 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,6 @@ ms.custom:
11
11
appliesto:
12
12
- ✅ Azure Cache for Redis
13
13
ms.devlang: golang
14
-
zone_pivot_groups: redis-type
15
14
---
16
15
17
16
# Quickstart: Use Azure Redis with Go
@@ -21,27 +20,27 @@ In this article, you learn how to use an Azure Redis cache with the Go language
21
20
## Prerequisites
22
21
23
22
- Azure subscription - [create one for free](https://azure.microsoft.com/free/)
24
-
-[Go](https://go.dev/doc/install)
25
-
-You must also add two imports from Redis to your project and add them to your development environment.
23
+
-Install [Go](https://go.dev/doc/install) language environment
24
+
-Add [two imports from Redis](https://redis.io/docs/latest/develop/clients/go/) to your project and to your development environment
26
25
-`entraid "github.com/redis/go-redis-entraid"`
27
26
-`"github.com/redis/go-redis/v9"`
28
27
29
28
## Create an Azure Managed Redis instance
30
29
31
-
First you must create a cache. You can create a cache using Azure Managed Redis or Azure Cache for Redis using the Azure portal. In this Quickstart, we use Azure Managed Redis.
30
+
First, create a cache. You can create a cache using Azure Managed Redis or Azure Cache for Redis using the Azure portal. In this Quickstart, we use Azure Managed Redis.
32
31
33
-
When you create the cache, you should create it Microsoft Entra ID is enabled by default. Your cache must also use public endpoint for this QuickStart.
32
+
When you create the cache, Microsoft Entra ID is enabled by default making it secure from the start. Your cache must also use a public endpoint for this QuickStart.
34
33
35
34
To create a cache with the portal, follow one of these procedures:
-[Azure Cache for Redis](/azure/azure-cache-for-redis/quickstart-create-redis)
39
38
40
-
Optionally, you can create a cache using Azure CLI, PowerShell, or any means that you prefer.
39
+
Optionally, you can create a cache using Azure CLI, PowerShell, whichever you prefer.
41
40
42
41
## Code to connect to a Redis cache
43
42
44
-
The first part of the code sample, you set your connection to your cache:
43
+
In the first part of the code sample, set your connection to the cache:
45
44
46
45
```go
47
46
package main
@@ -82,7 +81,7 @@ func main() {
82
81
83
82
## Code to test a connection
84
83
85
-
In the next section, we test the connection using the Redis command "ping" that returns the "pong" string.
84
+
In the next section, test the connection using the Redis command `ping` that returns the `pong` string.
86
85
87
86
```go
88
87
// Ping the Redis server to test the connection
@@ -95,7 +94,7 @@ In the next section, we test the connection using the Redis command "ping" that
95
94
96
95
## Code set a key, get a key
97
96
98
-
In this section, we show a basic `set` and `get` sequence to demonstrate using the Redis cache.
97
+
In this section, use a basic `set` and `get` sequence to start using the Redis cache in the simplest way to get started.
99
98
100
99
```go
101
100
// Do something with Redis and a key-value pair
@@ -120,19 +119,21 @@ In this section, we show a basic `set` and `get` sequence to demonstrate using t
120
119
121
120
```
122
121
123
-
Before you can run this code, you must add yourself as a Redis user. And you must also authorize your connection to Azure from the command line using the Azure command line or Azure developer command line (azd).
122
+
Before you can run this code, you must add yourself as a Redis user.
124
123
125
-
You should also [add any user](entra-for-authentication.md)[Add users or System principal to your cache](entra-for-authentication.md#add-users-or-system-principal-to-your-cache) who might run the program as a user on the Redis cache.
124
+
You must also authorize your connection to Azure from the command line using the Azure command line or Azure developer command line (azd).
125
+
126
+
You should also [add users or a System principal to your cache](entra-for-authentication.md#add-users-or-system-principal-to-your-cache). Add anyone who might run the program as a user on the Redis cache.
126
127
127
128
The result looks like this:
128
129
129
-
```
130
+
```console
130
131
Ping returned: PONG
131
132
SET Message succeeded: OK
132
133
GET Message returned: Hello, The cache is working with Go!
133
134
```
134
135
135
-
You can see this code sample in its entirety.
136
+
Here, you can see this code sample in its entirety.
136
137
137
138
```go
138
139
package main
@@ -152,7 +153,7 @@ func main() {
152
153
ctx:= context.Background()
153
154
154
155
// Set your Redis host (hostname:port)
155
-
redisHost:="<host >:<public port number>""
156
+
redisHost:="<host >:<public port number>"
156
157
157
158
// Create a credentials provider using DefaultAzureCredential
0 commit comments