Admin Keys - Regenerate

Regenerates either the primary or secondary admin API key. You can only regenerate one key at a time.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Search/searchServices/{searchServiceName}/regenerateAdminKey/{keyKind}?api-version=2024-03-01-preview

URI Parameters

Name In Required Type Description
keyKind
path True

AdminKeyKind

Specifies which key to regenerate. Valid values include 'primary' and 'secondary'.

resourceGroupName
path True

string

The name of the resource group within the current subscription. You can obtain this value from the Azure Resource Manager API or the portal.

searchServiceName
path True

string

The name of the Azure AI Search service associated with the specified resource group.

Regex pattern: ^(?=.{2,60}$)[a-z0-9][a-z0-9]+(-[a-z0-9]+)*$

subscriptionId
path True

string

The unique identifier for a Microsoft Azure subscription. You can obtain this value from the Azure Resource Manager API or the portal.

api-version
query True

string

The API version to use for each request.

Request Header

Name Required Type Description
x-ms-client-request-id

string

uuid

A client-generated GUID value that identifies this request. If specified, this will be included in response information as a way to track the request.

Responses

Name Type Description
200 OK

AdminKeyResult

The specified admin key was successfully regenerated. Both admin keys are included in the response, including the newly-regenerated key.

Other Status Codes

CloudError

HTTP 404 (Not Found): The subscription, resource group, or search service could not be found. HTTP 409 (Conflict): The specified subscription is disabled.

Security

azure_auth

Specifies an implicit grant flow, as supported on the Microsoft Identity platform.

Type: oauth2
Flow: implicit
Authorization URL: https://login.microsoftonline.com/common/oauth2/authorize

Scopes

Name Description
user_impersonation impersonate your user account

Examples

SearchRegenerateAdminKey

Sample request

POST https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Search/searchServices/mysearchservice/regenerateAdminKey/primary?api-version=2024-03-01-preview

Sample response

{
  "primaryKey": "<your primary admin API key>",
  "secondaryKey": "<your secondary admin API key>"
}

Definitions

Name Description
AdminKeyKind

Specifies which key to regenerate. Valid values include 'primary' and 'secondary'.

AdminKeyResult

Response containing the primary and secondary admin API keys for a given Azure AI Search service.

CloudError

Contains information about an API error.

CloudErrorBody

Describes a particular API error with an error code and a message.

AdminKeyKind

Specifies which key to regenerate. Valid values include 'primary' and 'secondary'.

Name Type Description
primary

string

The primary API key for the search service.

secondary

string

The secondary API key for the search service.

AdminKeyResult

Response containing the primary and secondary admin API keys for a given Azure AI Search service.

Name Type Description
primaryKey

string

The primary admin API key of the search service.

secondaryKey

string

The secondary admin API key of the search service.

CloudError

Contains information about an API error.

Name Type Description
error

CloudErrorBody

Describes a particular API error with an error code and a message.

message

string

A brief description of the error that hints at what went wrong (for details/debugging information refer to the 'error.message' property).

CloudErrorBody

Describes a particular API error with an error code and a message.

Name Type Description
code

string

An error code that describes the error condition more precisely than an HTTP status code. Can be used to programmatically handle specific error cases.

details

CloudErrorBody[]

Contains nested errors that are related to this error.

message

string

A message that describes the error in detail and provides debugging information.

target

string

The target of the particular error (for example, the name of the property in error).