Registries - Generate Credentials

Generate keys for a token of a specified container registry.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/generateCredentials?api-version=2025-11-01

URI Parameters

Name In Required Type Description
registryName
path True

string

minLength: 5
maxLength: 50
pattern: ^[a-zA-Z0-9]*$

The name of the container registry.

resourceGroupName
path True

string

minLength: 1
maxLength: 90

The name of the resource group. The name is case insensitive.

subscriptionId
path True

string (uuid)

The ID of the target subscription. The value must be an UUID.

api-version
query True

string

minLength: 1

The API version to use for this operation.

Request Body

Name Type Description
expiry

string (date-time)

The expiry date of the generated credentials after which the credentials become invalid.

name

TokenPasswordName

Specifies name of the password which should be regenerated if any -- password1 or password2.

tokenId

string

The resource ID of the token for which credentials have to be generated.

Responses

Name Type Description
200 OK

GenerateCredentialsResult

Azure operation completed successfully.

202 Accepted

Resource operation accepted.

Headers

  • Location: string
  • Retry-After: integer
Other Status Codes

ErrorResponse

An unexpected error response.

Security

azure_auth

Azure Active Directory OAuth2 Flow.

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

Scopes

Name Description
user_impersonation impersonate your user account

Examples

RegistryGenerateCredentials

Sample request

POST https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/generateCredentials?api-version=2025-11-01

{
  "tokenId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tokens/myToken",
  "expiry": "2020-12-31T15:59:59.0707808Z"
}

Sample response

{
  "username": "myToken",
  "passwords": [
    {
      "expiry": "2020-12-31T15:59:59.0707808Z",
      "name": "password1",
      "value": "00000000000000000000000000000000"
    },
    {
      "expiry": "2020-12-31T15:59:59.0707808Z",
      "name": "password2",
      "value": "00000000000000000000000000000000"
    }
  ]
}
Location: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/operationStatuses/registries-00000000-0000-0000-0000-000000000000?api-version=2025-11-01

Definitions

Name Description
ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

GenerateCredentialsParameters

The parameters used to generate credentials for a specified token or user of a container registry.

GenerateCredentialsResult

The response from the GenerateCredentials operation.

TokenPassword

The password that will be used for authenticating the token of a container registry.

TokenPasswordName

The password name "password1" or "password2"

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.

GenerateCredentialsParameters

The parameters used to generate credentials for a specified token or user of a container registry.

Name Type Description
expiry

string (date-time)

The expiry date of the generated credentials after which the credentials become invalid.

name

TokenPasswordName

Specifies name of the password which should be regenerated if any -- password1 or password2.

tokenId

string

The resource ID of the token for which credentials have to be generated.

GenerateCredentialsResult

The response from the GenerateCredentials operation.

Name Type Description
passwords

TokenPassword[]

The list of passwords for a container registry.

username

string

The username for a container registry.

TokenPassword

The password that will be used for authenticating the token of a container registry.

Name Type Description
creationTime

string (date-time)

The creation datetime of the password.

expiry

string (date-time)

The expiry datetime of the password.

name

TokenPasswordName

The password name "password1" or "password2"

value

string

The password value.

TokenPasswordName

The password name "password1" or "password2"

Value Description
password1
password2