How to import packages into Java project

Sung Oh Park (Contractor) 1 Reputation point
2022-02-16T18:18:36.18+00:00

I am currently having some issues importing packages into my java project.

I have set up the necessary dependencies required to use Microsoft packages, but when I try importing the packages it still does not identify the jar.

Any tips on how to resolve this?

My current dependencies are:
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-keyvault</artifactId>
<version>1.0.0</version>
</dependency>

Right now I am trying to connect to the KeyVaultCredentials.

My end goal is to connect to the key vault and obtain values after inputting the keys into the vault from the jar.

Please let me know what I may be missing or any other solutions that will help me achieve this.

Thank you

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,448 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Shweta Mathur 30,296 Reputation points Microsoft Employee Moderator
    2022-02-17T11:54:02.94+00:00

    Hi @Sung Oh Park (Contractor) ,

    Thanks for reaching out.

    I understand that you are looking for dependencies to add Azure Key Vault Secret client library for Java.

    First, you need to create resource group and key-vault using Azure Portal or Powershell and need to grant key vault permissions to your user account.

    To connect with Azure Key Vault , Azure Key Vault Secret client library for Java allows you to manage secrets for which you need to add below dependencies in your pom.xml file to the group of dependencies.

    <dependency>  
          <groupId>com.azure</groupId>  
          <artifactId>azure-security-keyvault-secrets</artifactId>  
          <version>4.2.3</version>  
        </dependency>  
        <dependency>  
          <groupId>com.azure</groupId>  
          <artifactId>azure-identity</artifactId>  
          <version>1.2.0</version>  
        </dependency>  
    

    and then need to import the below directives in java application file.

    import com.azure.security.keyvault.secrets.SecretClient;
    import com.azure.security.keyvault.secrets.SecretClientBuilder;
    import com.azure.security.keyvault.secrets.models.DeletedSecret;
    import com.azure.security.keyvault.secrets.models.KeyVaultSecret;

    Then you need to authenticate to key vault, Once application is authenticated, you can store and retrieve the secret from key vault.

    Reference doc: Quickstart - Azure Key Vault Secret client library for Java | Microsoft Learn

    Hope this will help.

    Thanks,
    Shweta

    ------------------------------------------

    Please remember to "Accept Answer" if answer helped you.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.