Skip to content

Commit

Permalink
Update README.md with documentation link
Browse files Browse the repository at this point in the history
  • Loading branch information
philon-msft committed May 12, 2023
1 parent bf168c2 commit 7c61218
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ Tags: Redis,Cache,StackExchange.Redis,Microsoft,Azure
---

# Microsoft.Azure.StackExchangeRedis Extension
Microsoft.Azure.StackExchangeRedis is an extension of StackExchange.Redis that enables using Azure Active Directory to authenticate connections from a Redis client application to an Azure Cache for Redis. The extension manages the authentication token, including proactively refreshing tokens before they expire to maintain persistent Redis connections over multiple days.
The Microsoft.Azure.StackExchangeRedis package is an extension for the StackExchange.Redis client library that enables using Azure Active Directory to authenticate connections from a Redis client application to an Azure Cache for Redis resource. This extension acquires an authentication token for a manged identity or service principal and configures a StackExchange.Redis connection to use the token for authentication. It also maintains the token, proactively refreshing it and re-authenticating the connection to maintain uninterrupted communication with the cache over multiple days.

## Usage
1. Add a reference to the [Microsoft.Azure.StackExchangeRedis NuGet package](https://www.nuget.org/packages/Microsoft.Azure.StackExchangeRedis) in your Redis client project
1. Add a reference to the [Microsoft.Azure.StackExchangeRedis](https://www.nuget.org/packages/Microsoft.Azure.StackExchangeRedis) NuGet package in your Redis client project

2. In your Redis connection code, create a `ConfigurationOptions` instance
```csharp
var configurationOptions = await ConfigurationOptions.Parse($"{cacheHostName}:6380");
```

3. Use one of the extension's methods to configure it for Azure:
3. Use one of the extension's methods to configure the options for Azure:
```csharp
// With a system-assigned managed identity
await configurationOptions.ConfigureForAzureWithSystemAssignedManagedIdentityAsync(principalId);
Expand All @@ -28,16 +28,16 @@ await configurationOptions.ConfigureForAzureWithUserAssignedManagedIdentityAsync
await configurationOptions.ConfigureForAzureWithServicePrincipalAsync(clientId, principalId, tenantId, secret);
```

4. Create the a connection by creating and passing in the ConfigurationOptions to the ConnectionMultiplexer.ConenctAsync
4. Create the connection, passing in the ConfigurationOptions instance
```csharp
var connectionMultiplexer = await ConnectionMultiplexer.ConnectAsync(configurationOptions);
```

## Running the sample
The `sample` directory contains a project showing how to connect to a Redis cache using the various authentication mechanisms supported by this extension. To run the sample:
The `sample` directory contains a project showing how to connect to a Redis cache using the various authentication mechanisms supported by this extension. You can borrow code from this sample for your own project, or simply run it to test the authentication configuration on your cache. It will prompt you for the type of authentication to use, and the specific credentials needed. To run the sample:
1. [Create an Azure Cache for Redis resource](https://learn.microsoft.com/azure/azure-cache-for-redis/quickstart-create-redis)
1. Create a [managed identity](https://learn.microsoft.com/azure/active-directory/managed-identities-azure-resources/qs-configure-cli-windows-vm#code-try-10) or [service principal](https://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal)
1. `dotnet run <path to Microsoft.Azure.StackExchangeRedis.Sample.csproj>`
1. Configure AAD authentication on your cache using the instructions in [Use Azure Active Directory for cache authentication](https://learn.microsoft.com/azure/azure-cache-for-redis/cache-azure-active-directory-for-authentication)
1. `dotnet run <path to Microsoft.Azure.StackExchangeRedis.Sample.csproj>`, or run the project in Visual Studio or your favorite IDE
1. Follow the prompts to enter your credentials and test the connection to the cache

NOTE: The sample project uses a `<ProjectReference>` to the extension project in this repo. To run the project on its own using the released Microsoft.Azure.StackExchangeRedis NuGet package, replace the `<ProjectReference>` in `Microsoft.Azure.StackExchangeRedis.Sample.csproj` with a `<PackageReference>`.
Expand All @@ -49,4 +49,4 @@ Please read our [CONTRIBUTING.md](CONTRIBUTING.md) which outlines all of our pol
We use [SemVer](https://semver.org/) for versioning. For the versions available, see the [releases](https://github.com/Azure/Microsoft.Azure.StackExchangeRedis/releases).

## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 comments on commit 7c61218

Please sign in to comment.