是否可以将Visual Studio的管理机密功能与Azure Service Fabric一起使用
我创建了一个Stateless ASP.net核心服务结构项目。我将一些配置移到了secret.json上,但是似乎没有从那里拿起它。似乎总是从appsetting.json中提取。
这是我的假设,因为我在启动时就提到了appsetting.json
return new WebHostBuilder()
.UseKestrel()
.ConfigureAppConfiguration((builderContext, config) =>
{
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
})
.ConfigureServices(
services => services
.AddSingleton<StatelessServiceContext>(serviceContext))
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.None)
.UseUrls(url)
.Build();
答案 0 :(得分:0)
是的,您应该可以这样做。 https://docs.microsoft.com/en-us/azure/service-fabric-mesh/service-fabric-mesh-howto-manage-secrets
有关如何在应用程序中使用/注入机密的此指南: https://docs.microsoft.com/azure/service-fabric-mesh/service-fabric-mesh-howto-manage-secrets#modify-mesh-application-to-reference-mesh-secret-values
有关如何正确声明机密资源的信息:https://docs.microsoft.com/azure/service-fabric-mesh/service-fabric-mesh-howto-manage-secrets#declare-a-mesh-secrets-resource
您可以将var secretPath = PathHelper.GetSecretsPathFromSecretsId(typeof(Program).Assembly.GetCustomAttribute<UserSecretsIdAttribute>().UserSecretsId);
添加到您的应用中,以查看将您的秘密配置存储在哪里。
它看起来像这样:
C:\Windows\System32\config\systemprofile\AppData\Roaming\Microsoft\UserSecrets\