Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="8.0.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../../../sdk/Core/Microsoft.UnifiedRedisPlatform.Core.csproj" />
<ProjectReference Include="..\..\..\sdk\Core\Microsoft.UnifiedRedisPlatform.Core.csproj" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Program
private static string _appName;
private static string _appSecret;
private static string _location;
private static string _managedIdentityClientId;
private static UnifiedConnectionMultiplexer _mux;
private static IUnifiedDatabase _database;
private static int _mode = AdvancedMode;
Expand Down Expand Up @@ -105,6 +106,7 @@ static void Main(string[] args)
AppName = _appName,
AppSecret = _appSecret,
Region = _location,
ManagedIdentityClientId = _managedIdentityClientId,
ConnectionRetryProtocol = connectionTimeout > 0 && connectionMaxRetry > 0 ? new RetryProtocol()
{
TimeoutInMs = connectionTimeout > 0 ? connectionTimeout : RetryProtocol.GetDefaultConnectionProtocol().TimeoutInMs,
Expand Down Expand Up @@ -135,7 +137,7 @@ static void Main(string[] args)

if (_mux == null)
{
_mux = UnifiedConnectionMultiplexer.Connect(_clusterName, _appName, _appSecret, preferredLocation: _location) as UnifiedConnectionMultiplexer;
_mux = UnifiedConnectionMultiplexer.Connect(_clusterName, _appName, _appSecret, managedIdentityClientId: _managedIdentityClientId, preferredLocation: _location) as UnifiedConnectionMultiplexer;
}

_database = _mux.GetDatabase() as IUnifiedDatabase;
Expand Down Expand Up @@ -219,6 +221,7 @@ private static void SetupDefaultAppDetails()
_appName = _configuration["AppName"];
_appSecret = _configuration["AppSecret"];
_location = _configuration["AppLocation"];
_managedIdentityClientId = _configuration["ManagedIdentityClientId"];

Console.WriteLine("Default configurations received.");
}
Expand All @@ -238,6 +241,9 @@ private static void SetAppDetails()

Console.Write("Region: ");
_location = Console.ReadLine();

Console.Write("Managed Identity Client ID (leave empty for local debugging): ");
_managedIdentityClientId = Console.ReadLine();
}

private static void ShowOperations()
Expand Down Expand Up @@ -322,7 +328,9 @@ private static void ShowAllKeys()
if (choice.KeyChar.ToString().ToLower() == "e")
return;

#pragma warning disable CS0618 // Perf issues are acceptable in Management Console
var keys = AsyncMode ? _mux.GetKeysAsync().Result : _mux.GetKeys();
#pragma warning restore CS0618
if (!keys.Any())
Console.WriteLine("No keys found in cache");
else
Expand Down Expand Up @@ -387,10 +395,12 @@ private static void Flush()
if (choice.KeyChar.ToString().ToLower() == "e")
return;

#pragma warning disable CS0618 // Perf issues are acceptable in Management Console
if (AsyncMode)
_mux.FlushAsync().Wait();
else
_mux.FlushAsync();
#pragma warning restore CS0618

Console.WriteLine("Cache flushed");
}
Expand All @@ -415,10 +425,12 @@ private static void FlushSecondary()
if (choice.KeyChar.ToString().ToLower() == "e")
return;

#pragma warning disable CS0618 // Perf issues are acceptable in Management Console
if (AsyncMode)
_mux.FlushSecondaryAsync().Wait();
else
_mux.FlushSecondary();
#pragma warning restore CS0618

Console.WriteLine("Cache flushed");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
{
"ClusterName": "PS-PreProd-01",
"AppName": "FXP-Service-SIT",
"AppSecret": "",
"AppLocation": "eastus"
"AppLocation": "eastus",
"ManagedIdentityClientId": ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Microsoft.UnifiedRedisPlatform.Manager.Domain.Commands
{
public class FlushKeysCommand : Command<KeysResult>
{
public override string DisplayName => "Flush Application Command";
public override string DisplayName => "Flush Keys Command";

private readonly string _id;
public override string Id => _id;
Expand All @@ -16,7 +16,7 @@ public class FlushKeysCommand : Command<KeysResult>
public string SearchText { get; set; }
public bool DeleteSecondary { get; set; }

public FlushKeysCommand(string cluster, string application, string searchText, bool deleteSecondary = false)
public FlushKeysCommand(string cluster, string application, string searchText, bool deleteSecondary)
{
_id = Guid.NewGuid().ToString();
Cluster = cluster;
Expand All @@ -25,20 +25,24 @@ public FlushKeysCommand(string cluster, string application, string searchText, b
DeleteSecondary = deleteSecondary;
}

public FlushKeysCommand(string cluster, string application)
: this(cluster, application, null)
public FlushKeysCommand(string cluster, string application, string searchText)
: this(cluster, application, searchText, false)
{ }

public override bool Validate(out string ValidationErrorMessage)
{
ValidationErrorMessage = null;

if (string.IsNullOrWhiteSpace(Cluster))
ValidationErrorMessage += "Cluster name cannot be empty.";
{
ValidationErrorMessage = "Cluster is not provided";
return false;
}
if (string.IsNullOrWhiteSpace(Application))
ValidationErrorMessage += "Application name cannot be empty.";

return string.IsNullOrWhiteSpace(ValidationErrorMessage);
{
ValidationErrorMessage = "Application is not provided";
return false;
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using AppInsights.EnterpriseTelemetry.Context;
using Microsoft.UnifiedPlatform.Service.Common.Configuration;
using Microsoft.UnifiedPlatform.Service.Common.Authentication;
using AppInsights.EnterpriseTelemetry;

namespace Microsoft.UnifiedRedisPlatform.Manager.Domain.Commands.Handlers
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CQRS.Mediatr.Lite" Version="1.0.0" />
<PackageReference Include="Microsoft.CQRS" Version="1.1.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\..\sdk\Core\Microsoft.UnifiedRedisPlatform.Core.csproj" />
<ProjectReference Include="..\..\..\..\service\Microsoft.UnifiedRedisPlatform.Service\SharedKernel\Common\Microsoft.UnifiedPlatform.Service.Common.csproj" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
using Microsoft.CQRS;
using System;
using Microsoft.CQRS;
using Microsoft.UnifiedPlatform.Service.Common.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.UnifiedRedisPlatform.Manager.Domain.Queries
{
public class GetKeyQuery : Query<UnifiedRedisKey>
{
public override string DisplayName => "Get Key Query";

private string _id;
private readonly string _id;
public override string Id => _id;

public string Cluster { get; set; }
Expand All @@ -28,15 +26,22 @@ public GetKeyQuery(string cluster, string application, string key)
public override bool Validate(out string ValidationErrorMessage)
{
ValidationErrorMessage = null;

if (string.IsNullOrWhiteSpace(Cluster))
ValidationErrorMessage += "Cluster name cannot be empty.";
{
ValidationErrorMessage = "Cluster is not provided";
return false;
}
if (string.IsNullOrWhiteSpace(Application))
ValidationErrorMessage += "Application name cannot be empty.";
{
ValidationErrorMessage = "Application is not provided";
return false;
}
if (string.IsNullOrWhiteSpace(Key))
ValidationErrorMessage += "Key cannot be empty";

return string.IsNullOrWhiteSpace(ValidationErrorMessage);
{
ValidationErrorMessage = "Key is not provided";
return false;
}
return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ public interface IUnifiedConnectionMultiplexerFactory

public class UnifiedConnectionMultiplexerFactory : IUnifiedConnectionMultiplexerFactory
{
private readonly string _managedIdentityClientId;

public UnifiedConnectionMultiplexerFactory(string managedIdentityClientId = null)
{
_managedIdentityClientId = managedIdentityClientId;
}

public IUnifiedConnectionMultiplexer Create(string clusterName, string applicationName, string appSecret)
{
return UnifiedConnectionMultiplexer.Connect(clusterName, applicationName, appSecret) as IUnifiedConnectionMultiplexer;
return UnifiedConnectionMultiplexer.Connect(clusterName, applicationName, appSecret, managedIdentityClientId: _managedIdentityClientId) as IUnifiedConnectionMultiplexer;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.UnifiedPlatform.S
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.UnifiedPlatform.Service.Common", "..\..\service\Microsoft.UnifiedRedisPlatform.Service\SharedKernel\Common\Microsoft.UnifiedPlatform.Service.Common.csproj", "{0C33A24D-5FE5-4566-9104-0F43E67FA798}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.UnifiedRedisPlatform.Core", "..\..\sdk\Microsoft.UnifiedRedisPlatform.SDK\Core\Microsoft.UnifiedRedisPlatform.Core.csproj", "{C45F1E14-800A-47C6-8E6D-3FB82A3AA743}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.UnifiedRedisPlatform.Core", "..\..\sdk\Core\Microsoft.UnifiedRedisPlatform.Core.csproj", "{C45F1E14-800A-47C6-8E6D-3FB82A3AA743}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.UnifiedPlatform.Storage", "..\..\service\Microsoft.UnifiedRedisPlatform.Service\Infrastructure\Storage\Microsoft.UnifiedPlatform.Storage.csproj", "{57DE9E2F-18B7-41F7-9435-FD9A0A446E05}"
EndProject
Expand Down
15 changes: 15 additions & 0 deletions src/manager/Microsoft.UnifiedRedisPlatform.Manager/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="PS-GCM-FieldExperiencePlatform" value="https://pkgs.dev.azure.com/MicrosoftIT/OneITVSO/_packaging/PS-GCM-FieldExperiencePlatform/nuget/v3/index.json" />
<add key="nuget.org-fallback" value="https://api.nuget.org/v3/index.json" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<activePackageSource>
<add key="All" value="(Aggregate source)" />
</activePackageSource>
</configuration>
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,14 @@ protected virtual void RegisterAuthenticators(ContainerBuilder builder)

protected virtual void RegisterRequestHandlerResolver(ContainerBuilder builder)
{
builder.RegisterType<UnifiedConnectionMultiplexerFactory>()
.As<IUnifiedConnectionMultiplexerFactory>()
.SingleInstance();
builder.Register(ctx =>
{
var config = ctx.Resolve<IConfiguration>();
var managedIdentityClientId = config["ManagedIdentityClientId"];
return new UnifiedConnectionMultiplexerFactory(managedIdentityClientId);
})
.As<IUnifiedConnectionMultiplexerFactory>()
.SingleInstance();

builder.Register(ctx =>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ApplicationInsightsResourceId>/subscriptions/05a315f7-744f-4692-b9dd-1aed7c6cee64/resourcegroups/RG-FieldExperiencePlatform-Dev-01/providers/microsoft.insights/components/aifxpdev</ApplicationInsightsResourceId>
</PropertyGroup>

Expand All @@ -10,13 +10,16 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.1.32" />
<PackageReference Include="Microsoft.FXP.Telemetry.Web.Extension" Version="1.0.0-beta.1" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="10.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.11" />
<PackageReference Include="Microsoft.CQRS" Version="1.1.0" />
<PackageReference Include="AppInsights.EnterpriseTelemetry" Version="1.0.2" />
<PackageReference Include="AppInsights.EnterpriseTelemetry.AspNetCore.Extension" Version="1.0.3" />
<PackageReference Include="Microsoft.Graph" Version="3.4.0" />
<PackageReference Include="Microsoft.Graph.Auth" Version="1.0.0-preview.4" />
<PackageReference Include="Microsoft.Identity.Client" Version="4.73.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="7.5.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="8.9.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.9.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

<ItemGroup>
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Autofac;
using System.IO;
using System.Reflection;
Expand Down Expand Up @@ -71,7 +71,7 @@ protected virtual void AddAuthentication(IServiceCollection services)

protected virtual void AddTelemetry(IServiceCollection services, IConfiguration configuration)
{
services.AddEnterpriseLogger(configuration);
services.AddEnterpriseTelemetry(configuration);
services.AddSingleton<IGlobalExceptionHandler, UnauthorizedUserExceptionHandler>();
services.AddSingleton<IGlobalExceptionHandler, GenericExceptionHandler>();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"Logging": {
"LogLevel": {
"Default": "Information",
Expand Down Expand Up @@ -60,5 +60,6 @@
"ConfigurationTable": "UnifiedRedisPlatform",
"BackoffInterval": 1000,
"MaxAttempt": 10
}
},
"ManagedIdentityClientId": "ddcbb4aa-01a9-46aa-8c11-03e1b789d9cd"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;

namespace Microsoft.UnifiedRedisPlatform.Manager.App.Data
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json;
using System;
using System.Linq;
using System.Net.Http;
Expand Down
Loading
Loading