Blob Containers - Lease

The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite.

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease?api-version=2023-01-01

URI Parameters

Name In Required Type Description
accountName
path True

string

The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and lower-case letters only.

Regex pattern: ^[a-z0-9]+$

containerName
path True

string

The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter or number.

resourceGroupName
path True

string

The name of the resource group within the user's subscription. The name is case insensitive.

Regex pattern: ^[-\w\._\(\)]+$

subscriptionId
path True

string

The ID of the target subscription.

api-version
query True

string

The API version to use for this operation.

Request Body

Name Required Type Description
action True

LeaseContainerRequestAction

Specifies the lease action. Can be one of the available actions.

breakPeriod

integer

Optional. For a break action, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60.

leaseDuration

integer

Required for acquire. Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires.

leaseId

string

Identifies the lease. Can be specified in any valid GUID string format.

proposedLeaseId

string

Optional for acquire, required for change. Proposed lease ID, in a GUID string format.

Responses

Name Type Description
200 OK

LeaseContainerResponse

OK -- Lease Container operation completed successfully.

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

Acquire a lease on a container
Break a lease on a container

Acquire a lease on a container

Sample Request

POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185/lease?api-version=2023-01-01

{
  "action": "Acquire",
  "leaseId": null,
  "breakPeriod": null,
  "leaseDuration": -1,
  "proposedLeaseId": null
}

Sample Response

{
  "leaseId": "8698f513-fa75-44a1-b8eb-30ba336af27d"
}

Break a lease on a container

Sample Request

POST https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/res3376/providers/Microsoft.Storage/storageAccounts/sto328/blobServices/default/containers/container6185/lease?api-version=2023-01-01

{
  "action": "Break",
  "leaseId": "8698f513-fa75-44a1-b8eb-30ba336af27d",
  "breakPeriod": null,
  "leaseDuration": null,
  "proposedLeaseId": null
}

Sample Response

{
  "leaseTimeSeconds": "0"
}

Definitions

Name Description
LeaseContainerRequest

Lease Container request schema.

LeaseContainerRequestAction

Specifies the lease action. Can be one of the available actions.

LeaseContainerResponse

Lease Container response schema.

LeaseContainerRequest

Lease Container request schema.

Name Type Description
action

LeaseContainerRequestAction

Specifies the lease action. Can be one of the available actions.

breakPeriod

integer

Optional. For a break action, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60.

leaseDuration

integer

Required for acquire. Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires.

leaseId

string

Identifies the lease. Can be specified in any valid GUID string format.

proposedLeaseId

string

Optional for acquire, required for change. Proposed lease ID, in a GUID string format.

LeaseContainerRequestAction

Specifies the lease action. Can be one of the available actions.

Name Type Description
Acquire

string

Break

string

Change

string

Release

string

Renew

string

LeaseContainerResponse

Lease Container response schema.

Name Type Description
leaseId

string

Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease.

leaseTimeSeconds

string

Approximate time remaining in the lease period, in seconds.