TAP-AzureKeyVault
1.0.1
dotnet add package TAP-AzureKeyVault --version 1.0.1
NuGet\Install-Package TAP-AzureKeyVault -Version 1.0.1
<PackageReference Include="TAP-AzureKeyVault" Version="1.0.1" />
paket add TAP-AzureKeyVault --version 1.0.1
#r "nuget: TAP-AzureKeyVault, 1.0.1"
// Install TAP-AzureKeyVault as a Cake Addin
#addin nuget:?package=TAP-AzureKeyVault&version=1.0.1
// Install TAP-AzureKeyVault as a Cake Tool
#tool nuget:?package=TAP-AzureKeyVault&version=1.0.1
Azure KeyVault Utility
The Azure KeyVault Utility is a C# library that simplifies working with Azure Key Vault. It includes features for key rotation and key retrieval, making it easier to manage cryptographic keys in your Azure Key Vault.
Table of Contents
- Azure KeyVault Utility
Introduction
Azure Key Vault is a secure and centralized service for managing secrets, keys, and certificates used by cloud applications and services. This utility simplifies interactions with Azure Key Vault by providing a set of C# classes and methods.
Features
- Key Rotation: Rotate keys in your Azure Key Vault, creating a new version with updated key material while preserving key attributes and tags.
- Key Retrieval: Retrieve keys from your Azure Key Vault.
Getting Started
Prerequisites
- .NET Core or .NET Framework installed on your development machine.
- An Azure subscription with an Azure Key Vault created and configured.
Installation
- You can import the
TAP-AzureKeyVault
library into your project using one of the methods below:
Using .NET CLI
To add the TAP-AzureKeyVault
library to your project using the .NET CLI, open a command prompt or terminal and navigate to your project's directory. Then run the following command:
dotnet add package TAP-AzureKeyVault --version 1.0.1
Using Package Manager (NuGet)
If you prefer using the Package Manager Console in Visual Studio, open the console and run the following command:
Install-Package TAP-AzureKeyVault -Version 1.0.1
Using PackageReference
If your project file uses the PackageReference format (common in .csproj files), add the following line to your project file:
<ItemGroup>
<PackageReference Include="TAP-AzureKeyVault" Version="1.0.1" />
</ItemGroup>
Using Paket CLI
To add the TAP-AzureKeyVault
library using the Paket CLI, run the following command:
paket add TAP-AzureKeyVault --version 1.0.1
Using Script & Interactive
For script and interactive scenarios, you can include the library by adding the following line:
#r "nuget: TAP-AzureKeyVault, 1.0.1"
Using Cake
For Cake build scripts, you can include the library as a Cake Addin or Tool using the following directives:
// Install TAP-AzureKeyVault as a Cake Addin
#addin nuget:?package=TAP-AzureKeyVault&version=1.0.1
// Install TAP-AzureKeyVault as a Cake Tool
#tool nuget:?package=TAP-AzureKeyVault&version=1.0.1
Using GIT
To clone the library directly from the GitHub repository, run the following GIT command:
git clone https://github.com/TouchAndPay-Technologies/TKV-TAPKeyVault-Lib_CSharp.git
Choose the method that best fits your development environment and project's requirements. After importing the library, you can start using it in your code.
- Open the project in your preferred development environment.
Configuration
- Open the
appsettings.json
file in the project. - Configure the following settings:
{
"AzureKeyVault": {
"VaultBaseUrl": "https://your-keyvault.vault.azure.net/",
"KeyName": "your-key-name"
},
"AzureActiveDirectory": {
"TenantId": "your-tenant-id",
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret"
}
}
Replace the placeholders with your actual Azure Key Vault and Azure Active Directory credentials.
Usage
Key Rotation
To rotate a key in your Azure Key Vault:
using AzureKeyVault;
var keyVault = new TapAzureKeyVault();
await keyVault.RotateKeyAsync("your-key-name");
Key Retrieval
To retrieve a key from your Azure Key Vault:
using AzureKeyVault;
var keyVault = new TapAzureKeyVault();
var key = await keyVault.GetKeyAsync("your-key-name");
Advanced
Dependency Injection
If you are using an ASP.NET Core application, you can register the TapAzureKeyVault
as a service and inject it where needed. Here's how:
In your
Startup.cs
file, add the service registration:using AzureKeyVault; public void ConfigureServices(IServiceCollection services) { var azureKeyConfig = new AzureKeyConfig { // Configure your AzureKeyConfig here }; services.AddAzureKeyVaultClient(azureKeyConfig); }
Inject the
IKeyVaultService
interface in your controller or service:using AzureKeyVault; public class MyService { private readonly IKeyVaultService _keyVaultService; public MyService(IKeyVaultService keyVaultService) { _keyVaultService = keyVaultService; } }
Contributing
We welcome contributions! If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes and write tests if necessary.
- Run the existing tests to ensure they pass.
- Submit a pull request.
License
This project is licensed under the Touchandpay License. See the LICENSE file for details.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- Azure.Identity (>= 1.10.3)
- Azure.Security.KeyVault.Keys (>= 4.5.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.