Class AzureKeyCredential
The AzureKeyCredential is used to authenticate and authorize requests made to Azure services.
It is specifically designed for scenarios where you need to authenticate using a key.
A key is a unique identifier or token that is associated with a specific user or application. It serves as a
simple form of authentication to ensure that only authorized clients can access the protected resources or APIs.
This authentication is commonly used for accessing certain services, such as Azure Cognitive Services, Azure Search,
or Azure Management APIs. Each service may have its own specific way of using API keys, but the general concept
remains the same. The AzureKeyCredential allows you to authenticate
using a key.
Code Samples
Create a key credential for a service key.
AzureKeyCredential azureKeyCredential = new AzureKeyCredential("AZURE-SERVICE-KEY");
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionAzureKeyCredential(String key) Creates a credential that authorizes request with the given key. -
Method Summary
Modifier and TypeMethodDescriptionRotates the key associated to this credential.Methods inherited from class com.azure.core.credential.KeyCredential
getKey
-
Constructor Details
-
AzureKeyCredential
Creates a credential that authorizes request with the given key.- Parameters:
key- The key used to authorize requests.- Throws:
NullPointerException- Ifkeyisnull.IllegalArgumentException- Ifkeyis an empty string.
-
-
Method Details
-
update
Rotates the key associated to this credential.- Overrides:
updatein classKeyCredential- Parameters:
key- The new key to associated with this credential.- Returns:
- The updated
AzureKeyCredentialobject. - Throws:
NullPointerException- Ifkeyisnull.IllegalArgumentException- Ifkeyis an empty string.
-