共用方式為


AzureKeyCredential Class

public final class AzureKeyCredential
extends KeyCredential

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");

Constructor Summary

Constructor Description
AzureKeyCredential(String key)

Creates a credential that authorizes request with the given key.

Method Summary

Modifier and Type Method and Description
AzureKeyCredential update(String key)

Rotates the key associated to this credential.

Methods inherited from KeyCredential

Methods inherited from java.lang.Object

Constructor Details

AzureKeyCredential

public AzureKeyCredential(String key)

Creates a credential that authorizes request with the given key.

Parameters:

key - The key used to authorize requests.

Method Details

update

public AzureKeyCredential update(String key)

Rotates the key associated to this credential.

Overrides:

AzureKeyCredential.update(String key)

Parameters:

key - The new key to associated with this credential.

Returns:

The updated AzureKeyCredential object.

Applies to