Access Azure Key Vault through Java
Refer to https://docs.microsoft.com/en-us/azure/key-vault/key-vault-whatis
- Application registration
- Azure Active Directory > Manage > App registrations
- Click "New application registration" and fill out the form (Redirect URL is not required).
- Take a note of Application (client) ID after registration is completed. This Application (client) ID is required to connect to Key Vault.
- Password
- Azure Active Directory > Manage > App registrations > Manage > "Client secrets" in Certificates & secrets section.
- Enter description, duration, and value.
- Click "Save", and value is changed. This changed value is "Client Secret", of which you have to take a note.
- Choose Key Vault in All Service or search for "key vault" in "Create a resource" and create with information added.
- Take a note of DNS name. This URL is required to connect Key Vault.
- Access Policies
- Click "Access Policies" in Settings, and click "Add new".
- Click "OK" after the following items are set.
- Select Principal : The application you registered.
- Secret permissions : Select "Get" in SEcret Management Operations
- Add secret to Key container
- Click "Secrets" in Settings and click "Generate/Import"
- Enter Name and Value. Name is the key when accessing key-value pair stored in Key Vault.
- Make sure created secret is enabled.
- Click "Create".
- Java Code
- Please refer to Azure Key Vault Key client library for Java
- This code sample used block() for description purpose. Do not use block() in production code.