![]() |
VOOZH | about |
dotnet add package Eaf.KeyVault.AspNetCore --version 9.1.0
NuGet\Install-Package Eaf.KeyVault.AspNetCore -Version 9.1.0
<PackageReference Include="Eaf.KeyVault.AspNetCore" Version="9.1.0" />
<PackageVersion Include="Eaf.KeyVault.AspNetCore" Version="9.1.0" />Directory.Packages.props
<PackageReference Include="Eaf.KeyVault.AspNetCore" />Project file
paket add Eaf.KeyVault.AspNetCore --version 9.1.0
#r "nuget: Eaf.KeyVault.AspNetCore, 9.1.0"
#:package Eaf.KeyVault.AspNetCore@9.1.0
#addin nuget:?package=Eaf.KeyVault.AspNetCore&version=9.1.0Install as a Cake Addin
#tool nuget:?package=Eaf.KeyVault.AspNetCore&version=9.1.0Install as a Cake Tool
O Eaf.KeyVault.AspNetCore é um módulo de integração ASP.NET Core para o Eaf.KeyVault. Este módulo fornece carregamento automático de configurações e segredos do Azure Key Vault ou Oracle Cloud Infrastructure (OCI) Vault diretamente no sistema de configuração do ASP.NET Core.
Este módulo simplifica a integração de segredos gerenciados em nuvem com aplicações ASP.NET Core, permitindo que configurações sensíveis sejam carregadas automaticamente durante o startup da aplicação.
Builder de configuração que carrega segredos do Key Vault:
Integração com ASP.NET Core Hosting:
dotnet add package Eaf.KeyVault.AspNetCore --version 10.4.0
Adicione a referência ao seu arquivo .csproj:
<ProjectReference Include="..\Eaf.KeyVault.AspNetCore\Eaf.KeyVault.AspNetCore.csproj" />
No Startup.cs ou Program.cs:
[DependsOn(
typeof(EafKeyVaultAspNetCoreModule),
typeof(EafKeyVaultModule)
)]
public class MyWebModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
}
}
public class Startup
{
public IConfiguration Configuration { get; }
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public void ConfigureServices(IServiceCollection services)
{
services.AddEafKeyVaultAspNetCore(options =>
{
options.Provider = "Azure";
options.Azure.VaultName = "my-vault-name";
options.Azure.TenantId = "your-tenant-id";
options.Azure.ClientId = "your-client-id";
options.Azure.ClientSecret = "your-client-secret";
});
}
}
public class MyService : ApplicationService
{
private readonly IConfiguration _configuration;
public MyService(IConfiguration configuration)
{
_configuration = configuration;
}
public string GetSecret()
{
return _configuration["MySecret"];
}
public string GetConnectionString()
{
return _configuration["ConnectionStrings:Default"];
}
}
public class Startup
{
public IConfigurationRoot Configuration { get; }
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
.SetBasePath(env.ContentRootPath)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
.AddEafKeyVault(); // Adiciona Key Vault como fonte de configuração
Configuration = builder.Build();
}
}
{
"KeyVault": {
"SecretMappings": {
"MyApp--ConnectionString": "ConnectionStrings:Default",
"MyApp--ApiKey": "ApiSettings:ApiKey",
"MyApp--SmtpPassword": "Smtp:Password"
}
}
}
public void ConfigureServices(IServiceCollection services)
{
services.AddEafKeyVaultAspNetCore(options =>
{
options.Provider = "Azure";
options.Azure.VaultName = "my-vault-name";
options.Azure.TenantId = "your-tenant-id";
options.Azure.ClientId = "your-client-id";
options.Azure.ClientSecret = "your-client-secret";
options.ReloadOnChange = true;
options.ReloadInterval = TimeSpan.FromMinutes(5);
});
}
Eaf.KeyVault.AspNetCore/
├── Hosting/ # Integração com ASP.NET Core Hosting
├── EafKeyVaultAspNetCoreModule.cs # Módulo ABP
└── Eaf.KeyVault.AspNetCore.csproj # Projeto
public void ConfigureServices(IServiceCollection services)
{
services.AddEafKeyVaultAspNetCore(options =>
{
options.SecretPrefix = "MyApp--";
});
}
public void ConfigureServices(IServiceCollection services)
{
services.AddEafKeyVaultAspNetCore(options =>
{
options.ExcludedSecrets = new[] { "TestSecret", "DevSecret" };
});
}
public void ConfigureServices(IServiceCollection services)
{
services.AddEafKeyVaultAspNetCore(options =>
{
options.Provider = "OCI";
options.OCI.VaultId = "ocid1.vault.oc1...";
options.OCI.Region = "us-ashburn-1";
options.OCI.TenancyId = "ocid1.tenancy.oc1...";
options.OCI.UserId = "ocid1.user.oc1...";
options.OCI.Fingerprint = "your-fingerprint";
options.OCI.PrivateKeyFilePath = "path/to/private_key.pem";
options.OCI.PrivateKeyPassphrase = "your-passphrase";
});
}
Os testes para este módulo devem ser criados seguindo o padrão dos outros módulos do EAF.
Este projeto faz parte do Enterprise Application Foundation (EAF) e está licenciado sob os mesmos termos do projeto principal.
Para issues e perguntas, consulte o repositório principal do EAF: https://github.com/afonsoft/EAF
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 9.1.0 | 81 | 6/17/2026 |