Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Microsoft.Azure.StackExchangeRedis to 3.1.0 #162

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public static void SetDeleter(
```

## Connection Types
There are three types of connections that are allowed from an Azure Functions instane to a Redis Cache.
There are three types of connections that are allowed from an Azure Functions instance to a Redis Cache.
In the appsettings, this is how to configure each of the following types of client authentication, assuming the `Connection` was set to `"Redis"` in the function.
1. Connection String
```json
Expand All @@ -218,13 +218,11 @@ In the appsettings, this is how to configure each of the following types of clie
1. System-Assigned Managed Identity
```json
"Redis:redisHostName": "<cacheName>.redis.cache.windows.net",
"Redis:principalId": "<principalId>"
```

1. User-Assigned Managed Identity
```json
"Redis:redisHostName": "<cacheName>.redis.cache.windows.net",
"Redis:principalId": "<principalId>",
"Redis:clientId": "<clientId>"
```

Expand All @@ -233,7 +231,6 @@ In the appsettings, this is how to configure each of the following types of clie
> Connections using Service Principal Secrets are only available during local development.
```json
"Redis:redisHostName": "<cacheName>.redis.cache.windows.net",
"Redis:principalId": "<principalId>",
"Redis:clientId": "<clientId>"
"Redis:tenantId": "<tenantId>"
"Redis:clientSecret": "<clientSecret>"
Expand Down
12 changes: 9 additions & 3 deletions samples/CosmosDBIntegration/Models/RedisData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static StreamData Format(StreamEntry entry, ILogger logger)
logger.LogInformation("ID: {val}", entry.Id.ToString());

// Map each key value pair
Dictionary<string, string> dict = RedisUtilities.StreamEntryToDictionary(entry);
Dictionary<string, string> dict = entry.ToDictionary();

StreamData sampleItem = new StreamData { id = entry.Id, values = dict };
return sampleItem;
Expand All @@ -35,7 +35,7 @@ public static StreamDataSingleDocument CreateNewEntry(StreamEntry entry, string
logger.LogInformation("Creating a new document for {val}. Inserting ID: {val} as the first entry", streamName, entry.Id.ToString());

// Map each key value pair
Dictionary<string, string> dict = RedisUtilities.StreamEntryToDictionary(entry);
Dictionary<string, string> dict = entry.ToDictionary();

// Create a new list of messages
var list = new Dictionary<string, Dictionary<string, string>>();
Expand All @@ -50,7 +50,7 @@ public static StreamDataSingleDocument UpdateExistingEntry(StreamDataSingleDocum
logger.LogInformation("Adding to {val} document. Inserting ID: {val} ", results.id, entry.Id.ToString());

// Map each key value pair
Dictionary<string, string> dict = RedisUtilities.StreamEntryToDictionary(entry);
Dictionary<string, string> dict = entry.ToDictionary();

// Update list of messages
var list = results.messages;
Expand Down Expand Up @@ -86,4 +86,10 @@ public record CosmosDBListData(
List<string> value
);

internal static class Extensions
{
internal static Dictionary<string, string> ToDictionary(this StreamEntry entry)
=> entry.Values.ToDictionary(value => value.Name.ToString(), value => value.Value.ToString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="4.3.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Redis" Version="0.3.1-preview" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Redis" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.122" />
<PackageReference Include="StackExchange.Redis" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Microsoft.Azure.Functions.Worker.Extensions.Redis\Microsoft.Azure.Functions.Worker.Extensions.Redis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="4.3.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Redis" Version="0.3.1-preview" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Redis" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.122" />
<PackageReference Include="StackExchange.Redis" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Microsoft.Azure.WebJobs.Extensions.Redis\Microsoft.Azure.WebJobs.Extensions.Redis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="4.3.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Redis" Version="0.3.1-preview" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.122" />
<PackageReference Include="StackExchange.Redis" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Microsoft.Azure.Functions.Worker.Extensions.Redis\Microsoft.Azure.Functions.Worker.Extensions.Redis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="4.3.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Redis" Version="0.3.1-preview" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="StackExchange.Redis" Version="2.6.122" />
<PackageReference Include="StackExchange.Redis" Version="2.8.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\src\Microsoft.Azure.Functions.Worker.Extensions.Redis\Microsoft.Azure.Functions.Worker.Extensions.Redis.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Azure.StackExchangeRedis" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.StackExchangeRedis" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.39" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="StackExchange.Redis" Version="2.7.4" />
<InternalsVisibleTo Include="Microsoft.Azure.WebJobs.Extensions.Redis.Tests" />
</ItemGroup>

Expand Down
10 changes: 1 addition & 9 deletions src/Microsoft.Azure.WebJobs.Extensions.Redis/RedisUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ internal static class RedisUtilities
public const string RedisOutputBinding = "RedisOutputBinding";

public const string EntraRedisHostName = "redisHostName";
public const string EntraPrincipalId = "principalId";

public const char BindingDelimiter = ' ';
public static Version Version62 = new Version("6.2");
Expand Down Expand Up @@ -81,15 +80,8 @@ public static async Task<ConfigurationOptions> ResolveConfigurationOptionsAsync(
else
{
// Entra Id Connections
string principalId = section[EntraPrincipalId];

if (string.IsNullOrWhiteSpace(principalId))
{
throw new ArgumentNullException($"{connection}__{EntraPrincipalId}");
}

TokenCredential tokenCredential = azureComponentFactory.CreateTokenCredential(section);
options = await ConfigurationOptions.Parse(cacheHostName).ConfigureForAzureWithTokenCredentialAsync(principalId, tokenCredential);
options = await ConfigurationOptions.Parse(cacheHostName).ConfigureForAzureWithTokenCredentialAsync(tokenCredential);
}

options.ClientName = GetRedisClientName(clientName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
<RepositoryUrl>https://github.com/Azure/azure-functions-redis-extension</RepositoryUrl>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="FakeItEasy" Version="7.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Host.Storage" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Azure" Version="1.7.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
Expand Down